online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
import unittest class sql_text_test(unittest.TestCase): ''' test class ''' class some_type: ''' just a helper class to test the type limitation of the text class ''' def __init__(self, data): self.data = data def test_prepare(self): for val in (self.some_type('bla'), complex(1, 2)): with self.assertRaises(TypeError): sql_text.prepare(val) self.assertEqual(str(""), "''") self.assertEqual(str("'"), "''''") self.assertEqual(str("''"), "''''''") self.assertEqual(str(''), "''") self.assertEqual(str(-1), "'-1'") self.assertEqual(str(1), "'1'") self.assertEqual(str(1.2), "'1.2'") # self.assertEqual(sql_text.prepare(None), "NULL") unnötig da None="NULL" def test_internals(self): ''' NOTE: there are no private members in python we therefore also need to test private functions we have already tested the "good" path of private member functions -> all we need to test are the type limitations (to proof turn on code coverage; should be 100%) ''' for function in (sql_text._none, sql_text._number, sql_text._str): for val in (self.some_type('bla'), complex(1, 2)): with self.assertRaises(TypeError): function(val) test = False # set to True to run tests in the text_test class if test: unittest.main() sql = "INSERT INTO tbl_foo (col_bar) VALUES" s = "\n " for val in (0, 1.2, "3.45°", '6.789s', None, "';SELECT 1;--"): sql += s + "('" + str(val) + "')" s = "\n ," sql += "\n;" print(sql)

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue