File tree Expand file tree Collapse file tree 4 files changed +41
-1
lines changed Expand file tree Collapse file tree 4 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ void KleeConstraintsPrinter::genConstraintsForMultiPointerOrArray(const Constrai
120120        std::vector<std::string> charSizes (indexes.begin (), indexes.end () - 1 );
121121        const  auto  charElement = constrMultiIndex (state.curElement , charSizes);
122122        ss << TAB_N () << " if (" back () << PrinterUtils::EQ_OPERATOR << sizes.back () - 1  << " )" LB ();
123-         ss << TAB_N () << charElement << " [" back () - 1  << " ]" ASSIGN_OPERATOR  << " '\\ 0'" 
123+         ss << TAB_N () << PrinterUtils::KLEE_ASSUME <<  " ( "  <<  charElement << " [" back () - 1  << " ]" EQ_OPERATOR  << " '\\ 0'"  <<  " ) " 
124124        ss << TAB_N () << " break" 
125125        ss << RB ();
126126    }
Original file line number Diff line number Diff line change @@ -238,4 +238,34 @@ namespace {
238238
239239        ASSERT_TRUE (status.ok ()) << status.error_message ();
240240    }
241+ 
242+     TEST_F (Regression_Test, Hash_Of_String) {
243+         fs::path source = getTestFilePath (" GH215.c" 
244+         auto  [testGen, status] = createTestForFunction (source, 2 );
245+ 
246+         ASSERT_TRUE (status.ok ()) << status.error_message ();
247+ 
248+         auto  predicate = [](const  tests::Tests::MethodTestCase &testCase) {
249+             auto  s = testCase.paramValues [0 ].view ->getEntryValue (nullptr );
250+             s = s.substr (1 , s.length () - 2 );
251+             auto  actual = testCase.returnValue .view ->getEntryValue (nullptr );
252+             auto  expected = std::to_string (std::accumulate (s.begin (), s.end (), 0 ));
253+             return  actual == expected;
254+         };
255+ 
256+         checkTestCasePredicates (
257+             testGen.tests .at (source).methods .begin ().value ().testCases ,
258+             std::vector<TestCasePredicate>(
259+                 { [&predicate](const  tests::Tests::MethodTestCase &testCase) {
260+                      //  empty string
261+                      return  testCase.paramValues [0 ].view ->getEntryValue (nullptr ).length () == 2  &&
262+                             predicate (testCase);
263+                  },
264+                   [&predicate](const  tests::Tests::MethodTestCase &testCase) {
265+                       //  non-empty string
266+                       return  testCase.paramValues [0 ].view ->getEntryValue (nullptr ).length () > 2  &&
267+                              predicate (testCase);
268+                   } }),
269+             " hash" 
270+     }
241271}
Original file line number Diff line number Diff line change @@ -38,4 +38,6 @@ add_library(PR124 PR124.c)
3838
3939add_library (PR153 PR153.c)
4040
41+ add_library (GH215 GH215.c)
42+ 
4143set_target_properties (regression PROPERTIES LINK_WHAT_YOU_USE TRUE )
Original file line number Diff line number Diff line change 1+ int  hash (const  char  * s ) {
2+     int  h  =  0 , i  =  0 ;
3+     while  (s [i ] !=  '\0' ) {
4+         h  =  (h  +  s [i ]);
5+         i ++ ;
6+     }
7+     return  h ;
8+ }
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments