| 1 | // Copyright 2015 Google Inc. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #include "decode_body.h" |
| 16 | #include "gtest/gtest.h" |
| 17 | |
| 18 | namespace libais { |
| 19 | namespace { |
| 20 | |
| 21 | TEST(CreateAisMsgTest, Invalid) { |
| 22 | EXPECT_EQ(nullptr, CreateAisMsg("", 0).get()); |
| 23 | EXPECT_EQ(nullptr, CreateAisMsg("L", 0).get()); |
| 24 | EXPECT_EQ(nullptr, CreateAisMsg("Z", 0).get()); |
| 25 | EXPECT_EQ(nullptr, CreateAisMsg("a", 0).get()); |
| 26 | EXPECT_EQ(nullptr, CreateAisMsg("z", 0).get()); |
| 27 | } |
| 28 | |
| 29 | TEST(CreateAisMsgTest, Valid) { |
| 30 | // !SAVDM,1,1,,B,K8VSqb9LdU28WP7h,0*4C |
| 31 | auto msg = CreateAisMsg("K8VSqb9LdU28WP7h", 0); |
| 32 | ASSERT_NE(nullptr, msg); |
| 33 | EXPECT_EQ(27, msg->message_id); |
| 34 | } |
| 35 | |
| 36 | } // namespace |
| 37 | } // namespace libais |