This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup forgoted `#ifdef`
- Loading branch information
Jiri Kratochvil
committed
Mar 9, 2016
1 parent
50a7a26
commit d6e34c6
Showing
5 changed files
with
100 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,3 @@ | |
## B (enum) | ||
- (A) | ||
- (array[A]) | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include "catch.hpp" | ||
|
||
#include "refract/Visitors.h" | ||
#include "refract/Element.h" | ||
|
||
#include "RefractElementFactory.h" | ||
|
||
|
||
using namespace refract; | ||
using namespace drafter; | ||
|
||
TEST_CASE("Create empty primitive element","[ElementFactory]") { | ||
RefractElementFactory& factory = FactoryFromType(mson::StringTypeName); | ||
IElement* e = factory.Create(std::string(), false); | ||
|
||
StringElement* str = TypeQueryVisitor::as<StringElement>(e); | ||
REQUIRE(str != NULL); | ||
REQUIRE(str->empty()); | ||
REQUIRE(str->meta.empty()); | ||
REQUIRE(str->attributes.empty()); | ||
REQUIRE(str->element() == StringElement::TraitType::element()); | ||
} | ||
|
||
TEST_CASE("Create primitive element w/ value","[ElementFactory]") { | ||
RefractElementFactory& factory = FactoryFromType(mson::NumberTypeName); | ||
IElement* e = factory.Create("42", false); | ||
|
||
NumberElement* number = TypeQueryVisitor::as<NumberElement>(e); | ||
REQUIRE(number != NULL); | ||
REQUIRE(!number->empty()); | ||
REQUIRE(number->meta.empty()); | ||
REQUIRE(number->attributes.empty()); | ||
REQUIRE(number->value == 42); | ||
} | ||
|
||
TEST_CASE("Create primitive element w/ sample","[ElementFactory]") { | ||
RefractElementFactory& factory = FactoryFromType(mson::NumberTypeName); | ||
IElement* e = factory.Create("42", true); | ||
|
||
NumberElement* number = TypeQueryVisitor::as<NumberElement>(e); | ||
REQUIRE(number != NULL); | ||
REQUIRE(number->empty()); | ||
REQUIRE(number->meta.empty()); | ||
|
||
REQUIRE(number->attributes.size() == 1); // sample attr | ||
IElement::MemberElementCollection::const_iterator it = number->attributes.find("samples"); | ||
REQUIRE((it != number->attributes.end())); | ||
} | ||
|
||
TEST_CASE("Create empty complex element","[ElementFactory]") { | ||
RefractElementFactory& factory = FactoryFromType(mson::EnumTypeName); | ||
IElement* e = factory.Create(std::string(), false); | ||
|
||
EnumElement* enm = TypeQueryVisitor::as<EnumElement>(e); | ||
REQUIRE(enm != NULL); | ||
REQUIRE(enm->empty()); | ||
REQUIRE(enm->meta.empty()); | ||
REQUIRE(enm->attributes.empty()); | ||
REQUIRE(enm->element() == EnumElement::TraitType::element()); | ||
} | ||
|
||
TEST_CASE("Create element as generic","[ElementFactory]") { | ||
RefractElementFactory& factory = FactoryFromType(mson::EnumTypeName); | ||
IElement* e = factory.Create("Enumerator", true); | ||
|
||
StringElement* generic = TypeQueryVisitor::as<StringElement>(e); | ||
REQUIRE(generic != NULL); | ||
REQUIRE(!generic->empty()); | ||
REQUIRE(generic->meta.empty()); | ||
REQUIRE(generic->attributes.empty()); | ||
REQUIRE(generic->element() == "generic"); | ||
REQUIRE(generic->value == "Enumerator"); | ||
} |