@@ -889,6 +889,38 @@ static void test_estimateVersionBoundaryCheck(void)
889889 testFinish ();
890890}
891891
892+ static void test_QRinput_new_invalid (void )
893+ {
894+ testStart ("Invalid input to QRinput_new2()" );
895+ QRinput * input ;
896+
897+ input = QRinput_new2 (-1 , QR_ECLEVEL_H );
898+ assert_null (input , "QRinput_new2() returns non-null for invalid version (-1).\n" );
899+ assert_equal (errno , EINVAL , "Error code is not EINVAL.\n" );
900+ input = QRinput_new2 (41 , QR_ECLEVEL_H );
901+ assert_null (input , "QRinput_new2() returns non-null for invalid version (41).\n" );
902+ assert_equal (errno , EINVAL , "Error code is not EINVAL.\n" );
903+ input = QRinput_new2 (1 , -1 );
904+ assert_null (input , "QRinput_new2() returns non-null for invalid level (-1).\n" );
905+ assert_equal (errno , EINVAL , "Error code is not EINVAL.\n" );
906+ input = QRinput_new2 (1 , 5 );
907+ assert_null (input , "QRinput_new2() returns non-null for invalid level (5).\n" );
908+ assert_equal (errno , EINVAL , "Error code is not EINVAL.\n" );
909+ testFinish ();
910+ }
911+
912+ static void test_QRinput_getErrorCorrectionLevel (void )
913+ {
914+ testStart ("Invalid input to QRinput_getErrorCorrectionLevel()" );
915+ QRinput * input ;
916+ QRecLevel level ;
917+
918+ input = QRinput_new2 (1 , QR_ECLEVEL_H );
919+ level = QRinput_getErrorCorrectionLevel (input );
920+ assert_equal (level , QR_ECLEVEL_H , "QRinput_getErrorCorrectionLevel() fails to return expected level.\n" );
921+ testFinish ();
922+ }
923+
892924static void test_mqr_new (void )
893925{
894926 QRinput * input ;
@@ -1044,7 +1076,7 @@ static void test_encodeECI(void)
10441076
10451077int main ()
10461078{
1047- int tests = 40 ;
1079+ int tests = 42 ;
10481080 testInit (tests );
10491081
10501082 test_encodeNumeric ();
@@ -1078,6 +1110,8 @@ int main()
10781110 test_parity2 ();
10791111 test_null_free ();
10801112 test_estimateVersionBoundaryCheck ();
1113+ test_QRinput_new_invalid ();
1114+ test_QRinput_getErrorCorrectionLevel ();
10811115
10821116 test_mqr_new ();
10831117 test_mqr_setversion ();
0 commit comments