integrate gtest framwork

This commit is contained in:
2024-03-26 04:52:12 +00:00
parent 347cfcf8e9
commit 68d185f12a
5 changed files with 55 additions and 4 deletions

View File

@ -243,7 +243,15 @@ class map {
map *domain;
public:
// Add some type traits
typedef std::bidirectional_iterator_tag iterator_category;
typedef pair<const Key, T> value_type;
typedef std::ptrdiff_t difference_type;
typedef value_type *pointer;
typedef value_type &reference;
friend const_iterator;
friend map;
iterator() : raw_pointer(nullptr), domain(nullptr) {}
iterator(const iterator &other) : raw_pointer(other.raw_pointer), domain(other.domain) {}
iterator(RedBlackTreeNodeType *raw_pointer, map *domain) : raw_pointer(raw_pointer), domain(domain) {}
@ -326,7 +334,15 @@ class map {
const map *domain;
public:
// Add some type traits
typedef std::bidirectional_iterator_tag iterator_category;
typedef pair<const Key, T> value_type;
typedef std::ptrdiff_t difference_type;
typedef value_type *pointer;
typedef value_type &reference;
friend iterator;
friend map;
const_iterator() : raw_pointer(nullptr), domain(nullptr) {}
const_iterator(const const_iterator &other) : raw_pointer(other.raw_pointer), domain(other.domain) {}
const_iterator(const iterator &other) : raw_pointer(other.raw_pointer), domain(other.domain) {}
@ -409,7 +425,7 @@ class map {
other.tree_root = nullptr;
}
/**
* TODO assignment operator
* assignment operator
*/
map &operator=(const map &other) {
if (this == &other) return *this;
@ -417,6 +433,7 @@ class map {
delete tree_root;
node_count = other.node_count;
CopyFrom(tree_root, other.tree_root);
return *this;
}
map &operator=(map &&other) {
if (this == &other) return *this;
@ -426,6 +443,7 @@ class map {
tree_root = other.tree_root;
other.node_count = 0;
other.tree_root = nullptr;
return *this;
}
~map() {
if (tree_root) tree_root->ReleaseAll();
@ -447,7 +465,6 @@ class map {
return result->val.second;
}
/**
* TODO
* access specified element
* Returns a reference to the value that is mapped to a key equivalent to key,
* performing an insertion if such key does not already exist.
@ -521,7 +538,9 @@ class map {
*
* throw if pos pointed to a bad element (pos == this->end() || pos points an element out of this)
*/
void erase(iterator pos) {}
void erase(iterator pos) {
if (pos.domain != this || pos.raw_pointer == nullptr) throw invalid_iterator();
}
/**
* Returns the number of elements with key
* that compares equivalent to the specified argument,