From 6a9bd209c3dcd4d152e8d19904d1f40af7b9d0c3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Mon, 16 Jul 2018 18:38:16 +0900 Subject: [PATCH] [nest] Add 'Bound' class (#668) This commit adds 'Bound' class which expresses value range of each variable as min/max. Signed-off-by: Jonghyun Park --- contrib/nest/include/nest/Bound.h | 31 +++++++++++++++++++++++++++++++ contrib/nest/src/Bound.test.cpp | 11 +++++++++++ 2 files changed, 42 insertions(+) create mode 100644 contrib/nest/include/nest/Bound.h create mode 100644 contrib/nest/src/Bound.test.cpp diff --git a/contrib/nest/include/nest/Bound.h b/contrib/nest/include/nest/Bound.h new file mode 100644 index 0000000..bad28c5 --- /dev/null +++ b/contrib/nest/include/nest/Bound.h @@ -0,0 +1,31 @@ +#ifndef __NEST_BOUND_H__ +#define __NEST_BOUND_H__ + +#include + +namespace nest +{ + +class Bound +{ +public: + Bound() = default; + +public: + Bound(int64_t min, int64_t max) : _min{min}, _max{max} + { + // DO NOTHING + } + +public: + int64_t min(void) const { return _min; } + int64_t max(void) const { return _max; } + +private: + int64_t _min; + int64_t _max; +}; + +} // namespace nest + +#endif // __NEST_BOUND_H__ diff --git a/contrib/nest/src/Bound.test.cpp b/contrib/nest/src/Bound.test.cpp new file mode 100644 index 0000000..6a7c83d --- /dev/null +++ b/contrib/nest/src/Bound.test.cpp @@ -0,0 +1,11 @@ +#include "nest/Bound.h" + +#include + +TEST(BOUND, ctor) +{ + const nest::Bound b{-10, 20}; + + ASSERT_EQ(b.min(), -10); + ASSERT_EQ(b.max(), 20); +} -- 2.7.4