@@ -15,15 +15,11 @@ contract StringsTest is DSTest {
15
15
}
16
16
17
17
function sign (int x ) private pure returns (int ) {
18
- return x/ abs (x );
18
+ return x == 0 ? int ( 0 ) : (x < 0 ? - 1 : int ( 1 ) );
19
19
}
20
20
21
21
function assertEq0 (string a , string b ) internal {
22
- if (a.len () != b.len ()) {
23
- emit log_bytes32 ("strings differ " );
24
- emit log_named_string ("Expected " , a);
25
- emit log_named_string ("Actual " , b);
26
- }
22
+ assertEq0 (bytes (a), bytes (b));
27
23
}
28
24
29
25
function assertEq0 (strings.slice memory a , strings.slice memory b ) internal {
@@ -47,6 +43,7 @@ contract StringsTest is DSTest {
47
43
}
48
44
}
49
45
46
+
50
47
function testToSliceB32 () public {
51
48
assertEq0 (bytes32 ("foobar " ).toSliceB32 (), "foobar " .toSlice ());
52
49
}
@@ -98,10 +95,7 @@ contract StringsTest is DSTest {
98
95
}
99
96
100
97
function testCompare () public {
101
- int compare = "foobie " .compare ("foobie " );
102
- emit log_named_int ("compare " , compare);
103
98
104
- assertEq (sign ("foobie " .toSlice ().compare ("foobie " .toSlice ())), 0 );
105
99
assertEq (sign ("foobie " .toSlice ().compare ("foobie " .toSlice ())), 0 );
106
100
assertEq (sign ("foobie " .toSlice ().compare ("foobif " .toSlice ())), - 1 );
107
101
assertEq (sign ("foobie " .toSlice ().compare ("foobid " .toSlice ())), 1 );
0 commit comments