MCPcopy Create free account
hub / github.com/PlatformLab/NanoLog / test_extractCString

Method test_extractCString

preprocessor/UnitTests.py:31–88  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

29 # self.foo = None
30
31 def test_extractCString(self):
32
33 self.assertEqual("This is a simple line",
34 extractCString(""" "This is a simple line" """))
35
36 string = " Here's a more complicated one\r\n on 2 lines"
37 self.assertEqual(string, extractCString("\"%s\"" % string))
38
39 string = " \\\"Escaped quotes!\\\" Noooo!!!"
40 self.assertEqual(string, extractCString("\"%s\"" % string))
41
42 string = "\\\\n Escaped new line"
43 self.assertEqual(string, extractCString("\"%s\"" % string))
44
45 string = "Multi line one \r\n that \n has \\\" an escaped quote"
46 self.assertEqual(string, extractCString("\"%s\"" % string))
47
48 string = "Format specifiers and special characters %s %d '#(*&(*79234'"
49 self.assertEqual(string, extractCString("\"%s\"" % string))
50
51 # Now work with C string concat, notice the style changed
52 string = " \" This is the real string \"\r\n \"and it's separated \""
53 self.assertEqual(" This is the real string and it's separated ",
54 extractCString(string))
55
56 string = "\r\n\r\n\r\n \"Weird\"\r\n\r\n "
57 self.assertEqual("Weird", extractCString(string))
58
59 string = """
60"This is a string"
61
62 " that's a bit" " more"
63 " representative\r\n"
64
65"""
66 self.assertEqual(
67 """This is a string that's a bit more representative\r\n""",
68 extractCString(string))
69
70 # Empty string
71 string = "\"\""
72 self.assertEqual("", extractCString(string))
73
74 # Finally, error cases where the string is malformed
75 string = "\""
76 self.assertIsNone(extractCString(string))
77
78 string = "\" One good string\" But another bad"
79 self.assertIsNone(extractCString(string))
80
81 string = "\" One\" \" and a half good strings"
82 self.assertIsNone(extractCString(string))
83
84 string = " \"Test\" extraneous chars"
85 self.assertIsNone(extractCString(string))
86
87 string = "\r\n\r\n\r\n \"Extra quote there =>\"\r\n\r\n \""
88 self.assertIsNone(extractCString(string))

Callers

nothing calls this directly

Calls 1

extractCStringFunction · 0.85

Tested by

no test coverage detected