squall/test/Array.cpp

62 lines
1.5 KiB
C++
Raw Normal View History

2020-11-01 17:45:45 -06:00
#include "storm/Array.hpp"
#include "storm/String.hpp"
2020-11-01 17:45:45 -06:00
#include "test/Test.hpp"
2020-09-24 23:33:18 -05:00
2020-12-08 19:42:37 -06:00
TEST_CASE("TSBaseArray", "[array]") {
2020-09-24 23:33:18 -05:00
SECTION("constructs correctly") {
TSBaseArray<uint32_t> array;
REQUIRE(array.Count() == 0);
}
}
2020-09-24 23:44:35 -05:00
TEST_CASE("TSBaseArray::MemFileName", "[array]") {
SECTION("returns a non-empty string") {
TSBaseArray<uint32_t> array;
REQUIRE(SStrLen(array.MemFileName()) > 0);
}
}
TEST_CASE("TSBaseArray::MemLineNo", "[array]") {
SECTION("returns a negative number") {
TSBaseArray<uint32_t> array;
REQUIRE(array.MemLineNo() < 0);
}
}
2020-12-08 19:42:37 -06:00
TEST_CASE("TSFixedArray", "[array]") {
2020-09-24 23:44:35 -05:00
SECTION("constructs correctly") {
TSFixedArray<uint32_t> array;
REQUIRE(array.Count() == 0);
}
}
2023-01-15 17:42:00 -06:00
TEST_CASE("TSFixedArray::Top", "[array]") {
SECTION("returns nullptr when array has no elements") {
TSFixedArray<uint32_t> array;
array.SetCount(0);
REQUIRE(array.Top() == nullptr);
}
SECTION("returns first element when array has 1 element") {
TSFixedArray<uint32_t> array;
array.SetCount(1);
array[0] = 1000;
REQUIRE(*array.Top() == 1000);
}
SECTION("returns last element when array has 2 elements") {
TSFixedArray<uint32_t> array;
array.SetCount(2);
array[0] = 1000;
array[1] = 1001;
REQUIRE(*array.Top() == 1001);
}
}
2020-12-08 19:42:37 -06:00
TEST_CASE("TSGrowableArray", "[array]") {
SECTION("constructs correctly") {
TSGrowableArray<uint32_t> array;
REQUIRE(array.Count() == 0);
}
}