Initial Course
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
#include "pointer_basics.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(PointerBasics, GetSetValue) {
|
||||
int x = 42;
|
||||
pointers::set_value(&x, 100);
|
||||
EXPECT_EQ(pointers::get_value(&x), 100);
|
||||
}
|
||||
|
||||
TEST(PointerBasics, IsNull) {
|
||||
EXPECT_TRUE(pointers::is_null(nullptr));
|
||||
int x = 1;
|
||||
EXPECT_FALSE(pointers::is_null(&x));
|
||||
}
|
||||
|
||||
TEST(PointerBasics, SwapViaPointers) {
|
||||
int a = 1, b = 2;
|
||||
pointers::swap_via_pointers(&a, &b);
|
||||
EXPECT_EQ(a, 2);
|
||||
EXPECT_EQ(b, 1);
|
||||
}
|
||||
Reference in New Issue
Block a user