feat(array): add TSBaseArray<T>::MemFileName

This commit is contained in:
fallenoak 2020-12-08 19:40:26 -06:00
parent 2e82693829
commit 787618142c
No known key found for this signature in database
GPG key ID: 7628F8E61AEA070D
2 changed files with 16 additions and 0 deletions

View file

@ -2,6 +2,7 @@
#define STORM_ARRAY_TS_BASE_ARRAY_HPP #define STORM_ARRAY_TS_BASE_ARRAY_HPP
#include <cstdint> #include <cstdint>
#include <typeinfo>
template <class T> template <class T>
class TSBaseArray { class TSBaseArray {
@ -10,6 +11,8 @@ class TSBaseArray {
uint32_t m_count = 0; uint32_t m_count = 0;
T* m_data = nullptr; T* m_data = nullptr;
virtual const char* MemFileName() const;
T& operator[](uint32_t i); T& operator[](uint32_t i);
uint32_t Count(void); uint32_t Count(void);
void Clear(void); void Clear(void);
@ -31,4 +34,9 @@ void TSBaseArray<T>::Clear() {
TSBaseArray<T>(); TSBaseArray<T>();
} }
template <class T>
const char* TSBaseArray<T>::MemFileName() const {
return typeid(T).name();
}
#endif #endif

View file

@ -1,4 +1,5 @@
#include "storm/Array.hpp" #include "storm/Array.hpp"
#include "storm/String.hpp"
#include "test/Test.hpp" #include "test/Test.hpp"
TEST_CASE("TSBaseArray", "[list]") { TEST_CASE("TSBaseArray", "[list]") {
@ -8,6 +9,13 @@ TEST_CASE("TSBaseArray", "[list]") {
} }
} }
TEST_CASE("TSBaseArray::MemFileName", "[array]") {
SECTION("returns a non-empty string") {
TSBaseArray<uint32_t> array;
REQUIRE(SStrLen(array.MemFileName()) > 0);
}
}
TEST_CASE("TSFixedArray", "[list]") { TEST_CASE("TSFixedArray", "[list]") {
SECTION("constructs correctly") { SECTION("constructs correctly") {
TSFixedArray<uint32_t> array; TSFixedArray<uint32_t> array;