Beispiel #1
0
    def test_bit_set_2(self):
        filename = join(self._path, "bit_set_2.ser")
        from_file = stream_read(filename)
        expected = {
            i * 3
            for i in range(100)
            if (i * 3) % 2 == 0 or i % 17 == 0 or i % 13 == 0
        }

        self.assertEqual(from_file, expected)
Beispiel #2
0
    def test_super_class_parser(self):

        filename = "object_w_parent_class.ser"
        from_file = stream_read(filename)
        expected = {
            'firstName': 'jim',
            'lastName': 'beam',
            'ssn': 83838,
            'age': 33,
            'array': [0] * 10,
            'siblings': [],
            'salary': 94399.00,
            'address': "2222 Aberdeen Dr. Mount Laurel, NJ 08054"
        }

        self.assertDictEqual(from_file, expected)
Beispiel #3
0
    def test_hash_map_Integer_String(self):
        filename = join(self._path, "hash_map_integer.ser")
        from_file = stream_read(filename)
        expected = {
            0: '0',
            1: '1',
            4: '16',
            9: '81',
            16: '256',
            25: '625',
            36: '1296',
            49: '2401',
            64: '4096',
            81: '6561'
        }

        self.assertDictEqual(from_file, expected)
Beispiel #4
0
    def test_2_level_hierarchy(self):
        filename = "object_w_parent_class_with_parent_class.ser"
        from_file = stream_read(filename)
        expected = {
            'firstName': 'michael',
            'lastName': 'scott',
            'ssn': 9393920,
            'age': 29,
            'array': [0] * 10,
            'siblings': [],
            'coworkers': [],
            'salary': 101022.00,
            'address': "2340 Aberdeen Dr. Mount Laurel, NJ 08054",
            'yearEndBonus': 0.0,
            'project': 'AWS'
        }

        self.assertDictEqual(from_file, expected)
Beispiel #5
0
    def test_class_with_multiple_collections(self):
        filename = join(self._path, "full_class_containers.ser")
        from_file = stream_read(filename)

        expected = {
            'arrayList': [0, 1, 8, 27, 64],
            'bitSet': {0, 12, 6},
            'linkedList': [0, 1, 4, 9, 16],
            'hashMap': {
                0: '0',
                1: '1',
                4: '16',
                9: '81',
                16: '256'
            },
            'hashSet': set(),
            'queue': [0, 1, 16, 81, 256]
        }
        self.assertDictEqual(from_file, expected)
Beispiel #6
0
 def test_class_descriptor_simple_class_2(self):
     filename = "object_w_nested_object_2.ser"
     from_file = stream_read(filename)
     expected = {
         'firstName':
         'jack',
         'lastName':
         'homan',
         'ssn':
         123456,
         'age':
         27,
         'array': [0] * 10,
         'siblings': [
             {
                 'firstName': 'ben',
                 'lastName': 'homan',
                 'ssn': 2345678,
                 'age': 28,
                 'siblings': [],
                 'array': [0] * 5
             },
             {
                 'firstName': 'kaila',
                 'lastName': 'mcnamara',
                 'ssn': 98765,
                 'age': 13,
                 'siblings': [],
                 'array': [0] * 10
             },
             {
                 'firstName': 'ashley',
                 'lastName': 'mcnamara',
                 'ssn': 9823702,
                 'age': 22,
                 'siblings': [],
                 'array': [0] * 10
             },
         ]
     }
     self.maxDiff = None
     self.assertDictEqual(from_file, expected)
Beispiel #7
0
 def test_class_descriptor_simple_class(self):
     filename = "object_w_nested_object.ser"
     from_file = stream_read(filename)
     expected = {
         'firstName':
         'jack',
         'lastName':
         'homan',
         'ssn':
         123456,
         'age':
         27,
         'siblings': [{
             'firstName': 'ben',
             'lastName': 'homan',
             'ssn': 2345678,
             'age': 28,
             'siblings': []
         }]
     }
     self.assertDictEqual(from_file, expected)
Beispiel #8
0
    def test_hash_set_empty(self):
        filename = join(self._path, "hash_set_string.ser")
        from_file = stream_read(filename)
        expected = set()

        self.assertEqual(from_file, expected)
Beispiel #9
0
    def test_priority_queue_integer(self):
        filename = join(self._path, "priority_queue_integer.ser")
        from_file = stream_read(filename)
        expected = [i**4 for i in range(10)]

        self.assertEqual(from_file, expected)
Beispiel #10
0
    def test_array_list_Integer(self):
        filename = join(self._path, "array_list_integer.ser")
        from_file = stream_read(filename)
        expected = [i**3 for i in range(10)]

        self.assertEqual(from_file, expected)
Beispiel #11
0
    def test_linked_list_integer(self):
        filename = join(self._path, "linked_list_integer.ser")
        from_file = stream_read(filename)
        expected = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

        self.assertEqual(from_file, expected)
Beispiel #12
0
    def test_bit_set_1(self):
        filename = join(self._path, "bit_set_1.ser")
        from_file = stream_read(filename)
        expected = {i for i in range(100) if (i % 2) == 0}

        self.assertEqual(from_file, expected)
Beispiel #13
0
    def test_bit_set(self):

        filename = join(self._path, "bit_set.ser")
        from_file = stream_read(filename)

        self.assertEqual(from_file, {0, 2, 4, 6, 8})
Beispiel #14
0
 def test_overloaded_privates(self):
     filename = "object_w_parent_class_with_parent_class_w_privates.ser"
     from_file = stream_read(filename)
     print()
     print()
     pprint(from_file)
Beispiel #15
0
 def test_aggragate_class_in_arraylist(self):
     filename = "object_w_parent_class_and_arraylist_aggregate.ser"
     from_file = stream_read(filename)
     print()
     print()
     pprint(from_file)