Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: unittests/Bitcode/NaClBitstreamReaderTest.cpp

Issue 1122423005: Add (unsupported experimental) feature allowing byte aligned bitcode. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Fix nits. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/NaCl/Bitcode/pnacl-bcdis/no-abbreviations.ll ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- llvm/unittest/Bitcode/NaClBitstreamReaderTest.cpp ------------------===// 1 //===- llvm/unittest/Bitcode/NaClBitstreamReaderTest.cpp ------------------===//
2 // Tests issues in NaCl Bitstream Reader. 2 // Tests issues in NaCl Bitstream Reader.
3 // 3 //
4 // The LLVM Compiler Infrastructure 4 // The LLVM Compiler Infrastructure
5 // 5 //
6 // This file is distributed under the University of Illinois Open Source 6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details. 7 // License. See LICENSE.TXT for details.
8 // 8 //
9 //===----------------------------------------------------------------------===// 9 //===----------------------------------------------------------------------===//
10 10
(...skipping 21 matching lines...) Expand all
32 32
33 // Tests that the default bitstream cursor is at bit zero. 33 // Tests that the default bitstream cursor is at bit zero.
34 TEST(NaClBitstreamTest, DefaultCursorAtBitZero) { 34 TEST(NaClBitstreamTest, DefaultCursorAtBitZero) {
35 uint8_t CursorMemory[sizeof(NaClBitstreamCursor)]; 35 uint8_t CursorMemory[sizeof(NaClBitstreamCursor)];
36 NaClBitstreamCursor *Cursor = 36 NaClBitstreamCursor *Cursor =
37 new (InitAltOnes(CursorMemory, sizeof(NaClBitstreamCursor))) 37 new (InitAltOnes(CursorMemory, sizeof(NaClBitstreamCursor)))
38 NaClBitstreamCursor(); 38 NaClBitstreamCursor();
39 EXPECT_EQ(BitZero, Cursor->GetCurrentBitNo()); 39 EXPECT_EQ(BitZero, Cursor->GetCurrentBitNo());
40 } 40 }
41 41
42 // Tests that when we initialize the bitstream cursor with a default bitstream
43 // reader, the cursor is at bit zero.
44 TEST(NaClBitstreamTest, CursorOnDefaultReaderAtBitZero) {
45 NaClBitstreamReader Reader;
46 uint8_t CursorMemory[sizeof(NaClBitstreamCursor)];
47 NaClBitstreamCursor *Cursor =
48 new (InitAltOnes(CursorMemory, sizeof(NaClBitstreamCursor)))
49 NaClBitstreamCursor(Reader);
50 EXPECT_EQ(BitZero, Cursor->GetCurrentBitNo());
51 }
52
53 // Tests that when we initialize the bitstream cursor with an array-filled 42 // Tests that when we initialize the bitstream cursor with an array-filled
54 // bitstream reader, the cursor is at bit zero. 43 // bitstream reader, the cursor is at bit zero.
55 TEST(NaClBitstreamTest, ReaderCursorAtBitZero) { 44 TEST(NaClBitstreamTest, ReaderCursorAtBitZero) {
56 static const size_t BufferSize = 12; 45 static const size_t BufferSize = 12;
57 unsigned char Buffer[BufferSize]; 46 unsigned char Buffer[BufferSize];
58 NaClBitstreamReader Reader(Buffer, Buffer+BufferSize); 47 NaClBitstreamReader Reader(
48 getNonStreamedMemoryObject(Buffer, Buffer+BufferSize), 0);
59 uint8_t CursorMemory[sizeof(NaClBitstreamCursor)]; 49 uint8_t CursorMemory[sizeof(NaClBitstreamCursor)];
60 NaClBitstreamCursor *Cursor = 50 NaClBitstreamCursor *Cursor =
61 new (InitAltOnes(CursorMemory, sizeof(NaClBitstreamCursor))) 51 new (InitAltOnes(CursorMemory, sizeof(NaClBitstreamCursor)))
62 NaClBitstreamCursor(Reader); 52 NaClBitstreamCursor(Reader);
63 EXPECT_EQ(BitZero, Cursor->GetCurrentBitNo()); 53 EXPECT_EQ(BitZero, Cursor->GetCurrentBitNo());
64 } 54 }
65 55
66 TEST(NaClBitstreamTest, CursorAtReaderInitialAddress) { 56 TEST(NaClBitstreamTest, CursorAtReaderInitialAddress) {
67 static const size_t BufferSize = 12; 57 static const size_t BufferSize = 12;
68 static const size_t InitialAddress = 8; 58 static const size_t InitialAddress = 8;
69 unsigned char Buffer[BufferSize]; 59 unsigned char Buffer[BufferSize];
70 NaClBitstreamReader Reader(Buffer, Buffer+BufferSize, InitialAddress); 60 NaClBitstreamReader Reader(
61 getNonStreamedMemoryObject(Buffer, Buffer+BufferSize), InitialAddress);
71 uint8_t CursorMemory[sizeof(NaClBitstreamCursor)]; 62 uint8_t CursorMemory[sizeof(NaClBitstreamCursor)];
72 NaClBitstreamCursor *Cursor = 63 NaClBitstreamCursor *Cursor =
73 new (InitAltOnes(CursorMemory, sizeof(NaClBitstreamCursor))) 64 new (InitAltOnes(CursorMemory, sizeof(NaClBitstreamCursor)))
74 NaClBitstreamCursor(Reader); 65 NaClBitstreamCursor(Reader);
75 EXPECT_EQ(InitialAddress * CHAR_BIT, Cursor->GetCurrentBitNo()); 66 EXPECT_EQ(InitialAddress * CHAR_BIT, Cursor->GetCurrentBitNo());
76 } 67 }
77 68
78 } // end of anonymous namespace 69 } // end of anonymous namespace
OLDNEW
« no previous file with comments | « test/NaCl/Bitcode/pnacl-bcdis/no-abbreviations.ll ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698