@@ -2057,6 +2057,7 @@ void main() {
20572057 LogicValue .ofRadixString (lv.toRadixString (radix: i)), equals (lv));
20582058 }
20592059 });
2060+
20602061 test ('radixString roundTrip with leading zeros' , () {
20612062 final lv = LogicValue .ofBigInt (BigInt .from (737481838713847 ), 61 );
20622063 for (final i in [2 , 4 , 8 , 10 , 16 ]) {
@@ -2066,6 +2067,7 @@ void main() {
20662067 equals (lv));
20672068 }
20682069 });
2070+
20692071 test ('radixString roundTrip zero corner case' , () {
20702072 final lv = LogicValue .ofBigInt (BigInt .from (0 ), 61 );
20712073 for (final i in [2 , 4 , 8 , 10 , 16 ]) {
@@ -2077,6 +2079,7 @@ void main() {
20772079 equals (lv));
20782080 }
20792081 });
2082+
20802083 test ('radixString binary expansion' , () {
20812084 final lv = LogicValue .ofRadixString ("12'b10z111011z00" );
20822085 expect (lv.toRadixString (radix: 16 ), equals ("12'h<10z1>d<1z00>" ));
@@ -2115,22 +2118,44 @@ void main() {
21152118 }
21162119 try {
21172120 lv.toRadixString (sepChar: 'q' );
2121+ fail ('Should throw a LogicValueConstructionException' );
21182122 } on Exception catch (e) {
21192123 expect (e, isA <LogicValueConversionException >());
21202124 }
21212125 try {
21222126 lv.toRadixString (radix: 14 );
2127+ fail ('Should throw a LogicValueConstructionException' );
21232128 } on Exception catch (e) {
21242129 expect (e, isA <LogicValueConversionException >());
21252130 }
21262131 });
2132+
21272133 test ('radixString space separators' , () {
21282134 final lv = LogicValue .ofRadixString ("10'b10 0010 0111" , sepChar: ' ' );
21292135 expect (lv.toInt (), equals (551 ));
21302136 });
2137+
2138+ test ('radixString bad input' , () {
2139+ try {
2140+ LogicValue .ofRadixString ('something' );
2141+ fail ('Should throw a LogicValueConstructionException' );
2142+ } on Exception catch (e) {
2143+ expect (e, isA <LogicValueConstructionException >());
2144+ }
2145+ });
2146+ test ('radixString bad input with fake length' , () {
2147+ try {
2148+ LogicValue .ofRadixString ("10'bsomething" );
2149+ fail ('Should throw a LogicValueConstructionException' );
2150+ } on Exception catch (e) {
2151+ expect (e, isA <LogicValueConstructionException >());
2152+ }
2153+ });
2154+
21312155 test ('radixString bad separator' , () {
21322156 try {
21332157 LogicValue .ofRadixString ("10'b10 0010_0111" );
2158+ fail ('Should throw a LogicValueConstructionException' );
21342159 } on Exception catch (e) {
21352160 expect (e, isA <LogicValueConstructionException >());
21362161 }
@@ -2139,19 +2164,24 @@ void main() {
21392164 test ('radixString illegal separator' , () {
21402165 try {
21412166 LogicValue .ofRadixString ("10'b10q0010q0111" , sepChar: 'q' );
2167+ fail ('Should throw a LogicValueConstructionException' );
21422168 } on Exception catch (e) {
21432169 expect (e, isA <LogicValueConstructionException >());
21442170 }
21452171 });
21462172
21472173 test ('radixString bad length' , () {
21482174 try {
2149- LogicValue .ofRadixString ("10'b10_0010_0111_0000" );
2175+ LogicValue .ofRadixString ("10'b10_0010_0111_0001" );
2176+ fail ('Should throw a LogicValueConstructionException' );
21502177 } on Exception catch (e) {
21512178 expect (e, isA <LogicValueConstructionException >());
21522179 }
2153- // Try the shortest possible input
2154- LogicValue .ofRadixString ("10'b" );
2180+ });
2181+
2182+ test ('radixString shortest possible length' , () {
2183+ final lv = LogicValue .ofRadixString ("10'b" );
2184+ expect (lv, equals (LogicValue .ofInt (0 , 10 )));
21552185 });
21562186
21572187 test ('radixString leading Z' , () {
@@ -2165,6 +2195,7 @@ void main() {
21652195 LogicValue .ofRadixString (lv.toRadixString (radix: i)), equals (lv));
21662196 }
21672197 });
2198+
21682199 test ('radixString decimal case' , () {
21692200 {
21702201 final lv = LogicValue .ofRadixString ("12'bzz_zzz1_1011" );
@@ -2195,6 +2226,7 @@ void main() {
21952226 LogicValue .ofRadixString (lv.toRadixString (radix: i)), equals (lv));
21962227 }
21972228 });
2229+
21982230 test ('radixString: slide set bits along entire word' , () {
21992231 final random = Random (5 );
22002232
0 commit comments