@@ -45,6 +45,40 @@ describe("SetHelper", () => {
4545 } ) ;
4646 } ) ;
4747
48+ describe ( "strictAdd" , ( ) => {
49+ it ( "should not strict add to address set if element already exists" , async ( ) => {
50+ await expect ( mock . strictAddToAddressSet ( [ FIRST . address , FIRST . address ] ) ) . to . be . revertedWith (
51+ "SetHelper: element already exists" ,
52+ ) ;
53+ } ) ;
54+
55+ it ( "should not strict add to uint set if element already exists" , async ( ) => {
56+ await expect ( mock . strictAddToUintSet ( [ 1 , 1 ] ) ) . to . be . revertedWith ( "SetHelper: element already exists" ) ;
57+ } ) ;
58+
59+ it ( "should strict add to string set if element already exists" , async ( ) => {
60+ await expect ( mock . strictAddToStringSet ( [ "1" , "1" ] ) ) . to . be . revertedWith ( "SetHelper: element already exists" ) ;
61+ } ) ;
62+
63+ it ( "should strict add to address set" , async ( ) => {
64+ await mock . strictAddToAddressSet ( [ FIRST . address , SECOND . address ] ) ;
65+
66+ expect ( await mock . getAddressSet ( ) ) . to . deep . equal ( [ FIRST . address , SECOND . address ] ) ;
67+ } ) ;
68+
69+ it ( "should strict add to uint set" , async ( ) => {
70+ await mock . strictAddToUintSet ( [ 1 ] ) ;
71+
72+ expect ( await mock . getUintSet ( ) ) . to . deep . equal ( [ 1n ] ) ;
73+ } ) ;
74+
75+ it ( "should strict add to string set" , async ( ) => {
76+ await mock . strictAddToStringSet ( [ "1" , "2" , "3" ] ) ;
77+
78+ expect ( await mock . getStringSet ( ) ) . to . deep . equal ( [ "1" , "2" , "3" ] ) ;
79+ } ) ;
80+ } ) ;
81+
4882 describe ( "remove" , ( ) => {
4983 it ( "should remove from address set" , async ( ) => {
5084 await mock . addToAddressSet ( [ FIRST . address , SECOND . address ] ) ;
@@ -67,4 +101,47 @@ describe("SetHelper", () => {
67101 expect ( await mock . getStringSet ( ) ) . to . deep . equal ( [ "3" , "2" ] ) ;
68102 } ) ;
69103 } ) ;
104+
105+ describe ( "remove" , ( ) => {
106+ it ( "should not strict remove from address set if no such element" , async ( ) => {
107+ await mock . strictAddToAddressSet ( [ FIRST . address , SECOND . address ] ) ;
108+
109+ await expect ( mock . strictRemoveFromAddressSet ( [ SECOND . address , SECOND . address ] ) ) . to . be . revertedWith (
110+ "SetHelper: no such element" ,
111+ ) ;
112+ } ) ;
113+
114+ it ( "should not strict remove from uint set if no such element" , async ( ) => {
115+ await mock . strictAddToUintSet ( [ 1 ] ) ;
116+
117+ await expect ( mock . strictRemoveFromUintSet ( [ 1 , 1 ] ) ) . to . be . revertedWith ( "SetHelper: no such element" ) ;
118+ } ) ;
119+
120+ it ( "should not strict remove from string set if no such element" , async ( ) => {
121+ await mock . strictAddToStringSet ( [ "1" , "2" , "3" ] ) ;
122+
123+ await expect ( mock . strictRemoveFromStringSet ( [ "1" , "1" ] ) ) . to . be . revertedWith ( "SetHelper: no such element" ) ;
124+ } ) ;
125+
126+ it ( "should strict remove from address set" , async ( ) => {
127+ await mock . strictAddToAddressSet ( [ FIRST . address , SECOND . address ] ) ;
128+ await mock . strictRemoveFromAddressSet ( [ SECOND . address ] ) ;
129+
130+ expect ( await mock . getAddressSet ( ) ) . to . deep . equal ( [ FIRST . address ] ) ;
131+ } ) ;
132+
133+ it ( "should strict remove from uint set" , async ( ) => {
134+ await mock . strictAddToUintSet ( [ 1 ] ) ;
135+ await mock . strictRemoveFromUintSet ( [ 1 ] ) ;
136+
137+ expect ( await mock . getUintSet ( ) ) . to . deep . equal ( [ ] ) ;
138+ } ) ;
139+
140+ it ( "should strict remove from string set" , async ( ) => {
141+ await mock . strictAddToStringSet ( [ "1" , "2" , "3" ] ) ;
142+ await mock . strictRemoveFromStringSet ( [ "1" ] ) ;
143+
144+ expect ( await mock . getStringSet ( ) ) . to . deep . equal ( [ "3" , "2" ] ) ;
145+ } ) ;
146+ } ) ;
70147} ) ;
0 commit comments