-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsubject_test.cpp
More file actions
63 lines (50 loc) · 2.05 KB
/
subject_test.cpp
File metadata and controls
63 lines (50 loc) · 2.05 KB
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
57
58
59
60
61
62
63
/*
Copyright (c) 2023 Snowplow Analytics Ltd. All rights reserved.
This program is licensed to you under the Apache License Version 2.0,
and you may not use this file except in compliance with the Apache License Version 2.0.
You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing,
software distributed under the Apache License Version 2.0 is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/
#include "../include/snowplow/subject.hpp"
#include "catch.hpp"
using namespace snowplow;
TEST_CASE("subject") {
Subject sub;
REQUIRE(sub.get_map().size() == 0);
SECTION("set_user_id adds a value for key uid") {
sub.set_user_id("some-uid");
REQUIRE(sub.get_map()["uid"] == "some-uid");
}
SECTION("set_screen_resolution adds a value for key res") {
sub.set_screen_resolution(1920, 1080);
REQUIRE(sub.get_map()["res"] == "1920x1080");
}
SECTION("set_viewport adds a value for key vp") {
sub.set_viewport(1080, 1080);
REQUIRE(sub.get_map()["vp"] == "1080x1080");
}
SECTION("set_color_depth adds a value for key cd") {
sub.set_color_depth(32);
REQUIRE(sub.get_map()["cd"] == "32");
}
SECTION("set_timezone adds a value for key tz") {
sub.set_timezone("GMT");
REQUIRE(sub.get_map()["tz"] == "GMT");
}
SECTION("set_language adds a value for key lang") {
sub.set_language("EN");
REQUIRE(sub.get_map()["lang"] == "EN");
}
SECTION("set_useragent adds a value for key ua") {
string useragent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.78.2 (KHTML, like Gecko) Version/7.0.6 Safari/537.78.2";
sub.set_useragent(useragent);
REQUIRE(sub.get_map()["ua"] == useragent);
}
SECTION("set_ip_address adds a value for key ip") {
sub.set_ip_address("192.168.0.1");
REQUIRE(sub.get_map()["ip"] == "192.168.0.1");
}
}