@@ -59,3 +59,44 @@ TEST(RuntimeContextTest, ThreeAttachDetach)
59
59
EXPECT_TRUE (context::RuntimeContext::Detach (foo_context_token));
60
60
EXPECT_TRUE (context::RuntimeContext::Detach (test_context_token));
61
61
}
62
+
63
+ // Tests that SetValue returns a context with the passed in data and the
64
+ // RuntimeContext data when a context is not passed into the
65
+ // RuntimeContext::SetValue method.
66
+ TEST (RuntimeContextTest, SetValueRuntimeContext)
67
+ {
68
+ context::Context foo_context = context::Context (" foo_key" , (int64_t )596 );
69
+ context::RuntimeContext::Token old_context_token = context::RuntimeContext::Attach (foo_context);
70
+ context::Context test_context = context::RuntimeContext::SetValue (" test_key" , (int64_t )123 );
71
+ EXPECT_EQ (nostd::get<int64_t >(test_context.GetValue (" test_key" )), 123 );
72
+ EXPECT_EQ (nostd::get<int64_t >(test_context.GetValue (" foo_key" )), 596 );
73
+ }
74
+
75
+ // Tests that SetValue returns a context with the passed in data and the
76
+ // passed in context data when a context* is passed into the
77
+ // RuntimeContext::SetValue method.
78
+ TEST (RuntimeContextTest, SetValueOtherContext)
79
+ {
80
+ context::Context foo_context = context::Context (" foo_key" , (int64_t )596 );
81
+ context::Context test_context =
82
+ context::RuntimeContext::SetValue (" test_key" , (int64_t )123 , &foo_context);
83
+ EXPECT_EQ (nostd::get<int64_t >(test_context.GetValue (" test_key" )), 123 );
84
+ EXPECT_EQ (nostd::get<int64_t >(test_context.GetValue (" foo_key" )), 596 );
85
+ }
86
+
87
+ // Tests that SetValue returns the ContextValue associated with the
88
+ // passed in string and the current Runtime Context
89
+ TEST (RuntimeContextTest, GetValueRuntimeContext)
90
+ {
91
+ context::Context foo_context = context::Context (" foo_key" , (int64_t )596 );
92
+ context::RuntimeContext::Token old_context_token = context::RuntimeContext::Attach (foo_context);
93
+ EXPECT_EQ (nostd::get<int64_t >(context::RuntimeContext::GetValue (" foo_key" )), 596 );
94
+ }
95
+
96
+ // Tests that SetValue returns the ContextValue associated with the
97
+ // passed in string and the passed in context
98
+ TEST (RuntimeContextTest, GetValueOtherContext)
99
+ {
100
+ context::Context foo_context = context::Context (" foo_key" , (int64_t )596 );
101
+ EXPECT_EQ (nostd::get<int64_t >(context::RuntimeContext::GetValue (" foo_key" , &foo_context)), 596 );
102
+ }
0 commit comments