MCPcopy Create free account
hub / github.com/1345414527/MIT6.830 / combine

Method combine

test/simpledb/TupleDescTest.java:21–50  ·  view source on GitHub ↗

Unit test for TupleDesc.combine()

()

Source from the content-addressed store, hash-verified

19 * Unit test for TupleDesc.combine()
20 */
21 @Test public void combine() {
22 TupleDesc td1, td2, td3;
23
24 td1 = Utility.getTupleDesc(1, "td1");
25 td2 = Utility.getTupleDesc(2, "td2");
26
27 // test td1.combine(td2)
28 td3 = TupleDesc.merge(td1, td2);
29 assertEquals(3 , td3.numFields());
30 assertEquals(3 * Type.INT_TYPE.getLen(), td3.getSize());
31 for (int i = 0; i < 3; ++i)
32 assertEquals(Type.INT_TYPE, td3.getFieldType(i));
33 assertTrue(combinedStringArrays(td1, td2, td3));
34
35 // test td2.combine(td1)
36 td3 = TupleDesc.merge(td2, td1);
37 assertEquals(3 , td3.numFields());
38 assertEquals(3 * Type.INT_TYPE.getLen(), td3.getSize());
39 for (int i = 0; i < 3; ++i)
40 assertEquals(Type.INT_TYPE, td3.getFieldType(i));
41 assertTrue(combinedStringArrays(td2, td1, td3));
42
43 // test td2.combine(td2)
44 td3 = TupleDesc.merge(td2, td2);
45 assertEquals(4 , td3.numFields());
46 assertEquals(4 * Type.INT_TYPE.getLen(), td3.getSize());
47 for (int i = 0; i < 4; ++i)
48 assertEquals(Type.INT_TYPE, td3.getFieldType(i));
49 assertTrue(combinedStringArrays(td2, td2, td3));
50 }
51
52 /**
53 * Ensures that combined's field names = td1's field names + td2's field names

Callers

nothing calls this directly

Calls 7

getTupleDescMethod · 0.95
mergeMethod · 0.95
numFieldsMethod · 0.95
getSizeMethod · 0.95
getFieldTypeMethod · 0.95
combinedStringArraysMethod · 0.95
getLenMethod · 0.80

Tested by

no test coverage detected