From 0de5f269060f1865234215427448312742218a3b Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Sat, 24 Dec 2016 22:55:00 +0100
Subject: [PATCH] test same types in variant

---
 alib2std/test-src/extensions/VariantTest.cpp | 14 ++++++++++++++
 alib2std/test-src/extensions/VariantTest.h   |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/alib2std/test-src/extensions/VariantTest.cpp b/alib2std/test-src/extensions/VariantTest.cpp
index 0e18172045..93fd9a0c6a 100644
--- a/alib2std/test-src/extensions/VariantTest.cpp
+++ b/alib2std/test-src/extensions/VariantTest.cpp
@@ -144,3 +144,17 @@ void VariantTest::testVariantDefault() {
 
 	CPPUNIT_ASSERT ( v3.get<int> ( ) == 0 );
 }
+
+void VariantTest::testVariantSameTypes() {
+	std::variant < int, int, char > v1 ( 1 );
+
+	CPPUNIT_ASSERT ( v1.get < int > ( ) == 1 );
+
+	v1.set < char > ( 'a' );
+
+	CPPUNIT_ASSERT ( v1.get < char > ( ) == 'a' );
+
+	v1.set < int > ( 'a' );
+
+	CPPUNIT_ASSERT ( v1.is < int > ( ) );
+}
diff --git a/alib2std/test-src/extensions/VariantTest.h b/alib2std/test-src/extensions/VariantTest.h
index 369a55490f..f7804de2cc 100644
--- a/alib2std/test-src/extensions/VariantTest.h
+++ b/alib2std/test-src/extensions/VariantTest.h
@@ -12,6 +12,7 @@ class VariantTest : public CppUnit::TestFixture
   CPPUNIT_TEST( testVariantSet2 );
   CPPUNIT_TEST( testVariantVoid );
   CPPUNIT_TEST( testVariantDefault );
+  CPPUNIT_TEST( testVariantSameTypes );
   CPPUNIT_TEST_SUITE_END();
 
 public:
@@ -72,6 +73,7 @@ public:
   void testVariantSet2();
   void testVariantVoid();
   void testVariantDefault();
+  void testVariantSameTypes();
 };
 
 namespace std {
-- 
GitLab