• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2016 The WebM project authors. All Rights Reserved.
2 //
3 // Use of this source code is governed by a BSD-style license
4 // that can be found in the LICENSE file in the root of the source
5 // tree. An additional intellectual property rights grant can be found
6 // in the file PATENTS.  All contributing project authors may
7 // be found in the AUTHORS file in the root of the source tree.
8 #include "src/id_element_parser.h"
9 
10 #include "gtest/gtest.h"
11 
12 #include "test_utils/element_parser_test.h"
13 #include "webm/element.h"
14 #include "webm/id.h"
15 #include "webm/status.h"
16 
17 using webm::ElementParserTest;
18 using webm::Id;
19 using webm::IdElementParser;
20 using webm::kUnknownElementSize;
21 using webm::Status;
22 
23 namespace {
24 
25 class IdElementParserTest : public ElementParserTest<IdElementParser> {};
26 
TEST_F(IdElementParserTest,InvalidSize)27 TEST_F(IdElementParserTest, InvalidSize) {
28   TestInit(0, Status::kInvalidElementSize);
29   TestInit(5, Status::kInvalidElementSize);
30   TestInit(kUnknownElementSize, Status::kInvalidElementSize);
31 }
32 
TEST_F(IdElementParserTest,ValidId)33 TEST_F(IdElementParserTest, ValidId) {
34   SetReaderData({0xEC});
35   ParseAndVerify();
36   EXPECT_EQ(Id::kVoid, parser_.value());
37 
38   SetReaderData({0x1F, 0x43, 0xB6, 0x75});
39   ParseAndVerify();
40   EXPECT_EQ(Id::kCluster, parser_.value());
41 }
42 
TEST_F(IdElementParserTest,IncrementalParse)43 TEST_F(IdElementParserTest, IncrementalParse) {
44   SetReaderData({0x2A, 0xD7, 0xB1});
45 
46   IncrementalParseAndVerify();
47 
48   EXPECT_EQ(Id::kTimecodeScale, parser_.value());
49 }
50 
51 }  // namespace
52