-
Notifications
You must be signed in to change notification settings - Fork 3
/
VinDecoderTest.cpp
56 lines (43 loc) · 1.6 KB
/
VinDecoderTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <gtest/gtest.h>
#include <../include/VinDecoder.h>
// try to validate a valid VIN
TEST(VinDecoderTest, ValidateGoodVIN) {
auto decoder = VinDecoder();
auto goodValidation = decoder.validate("WMWMS335X9TY38985");
ASSERT_TRUE(goodValidation);
};
// Try to decode a valid VIN
TEST(VinDecoderTest, DecodeGoodVIN) {
auto decoder = VinDecoder();
auto goodResult = decoder.decode("WMWMS335X9TY38985");
ASSERT_TRUE(goodResult->country == "Germany");
ASSERT_TRUE(goodResult->manufacturer == "MINI");
ASSERT_TRUE(goodResult->serialNumber == "T");
};
// Try a vin that is shorter than 17 characters
TEST(VinDecoderTest, ValidateTooShortVIN) {
auto decoder = VinDecoder();
auto tooShortValidation = decoder.validate("WMWMS335X9TY3898");
ASSERT_FALSE(tooShortValidation);
};
// Try a vin that is longer than 17 characters
TEST(VinDecoderTest, ValidateTooLongVIN) {
auto decoder = VinDecoder();
auto tooShortValidation = decoder.validate("WMWMS335X9TY389850");
ASSERT_FALSE(tooShortValidation);
};
// Try a VIN whose sum is off
TEST(VinDecoderTest, ValidateMistypedVIN) {
auto decoder = VinDecoder();
auto invalidSumValidation = decoder.validate("WMWMS335X8TY38985");
ASSERT_FALSE(invalidSumValidation);
};
// Try to decode a VIN whose sum is off
TEST(VinDecoderTest, DecodeBadVIN) {
auto decoder = VinDecoder();
auto badResult = decoder.decode("WMWMS335X8TY38985");
ASSERT_FALSE(badResult->isValid);
ASSERT_TRUE(badResult->country == "");
ASSERT_TRUE(badResult->manufacturer == "");
ASSERT_TRUE(badResult->serialNumber == "");
};