Esempio n. 1
0
 def test_strcmp(self):
     output = self.run('''
     echo strcmp("aa", "aaaa");
     echo strcmp("aa", "aba");
     echo strcmp("aba", "aa");
     echo strcmp("aba", "aba");
     echo strcmp(3, 25);
     ''')
     assert [intsign(self.space.int_w(i)) for i in output] == [
             -1, -1, 1, 0, 1]
Esempio n. 2
0
 def test_strncmp(self):
     output = self.run('''
     echo strncmp(123, 12, 2);
     echo strncmp("abc", "xyz", 1);
     echo strncmp("abc", "", 0);
     echo strncmp("abc", "", 10);
     ''')
     assert [intsign(self.space.int_w(i)) for i in output] == [0, -1, 0, 1]
     output = self.run('echo strncmp("abc", "xyz", -1);', [
         "Warning: Length must be greater than or equal to 0"])
     assert self.space.is_w(output[0], self.space.w_False)
Esempio n. 3
0
 def test_strcasecmp(self):
     output = self.run('''
     echo strcasecmp("AA", "aaaa");
     echo strcasecmp("AA", "abA");
     echo strcasecmp("Aba", "aA");
     echo strcasecmp("Aba", "Aba");
     echo strcasecmp(3, 25);
     echo strcasecmp("_", "A");
     ''')  # NB: 'A' < '_' < 'a'
     assert [intsign(self.space.int_w(i)) for i in output] == [
             -1, -1, 1, 0, 1, -1]
Esempio n. 4
0
 def test_substr_compare(self):
     output = self.run('''
     echo substr_compare("abcde", "bc", 1);
     echo substr_compare("abcde", "bc", 1, 2);
     echo substr_compare("abcde", "de", -2, 2);
     echo substr_compare("abcde", "bcg", 1, 2);
     echo substr_compare("abcde", "BC", 1, 2, true);
     echo substr_compare("abcde", "bc", 1, 3);
     echo substr_compare("abcde", "cd", 1, 2);
     echo substr_compare("abcde", "abcdef", -10, 10);
     ''')
     assert [intsign(self.space.int_w(i)) for i in output] == [
             1, 0, 0, 0, 0, 1, -1, -1]
Esempio n. 5
0
def test_intsign(input, expected):
    assert intsign(input) == expected