TestNameId.cpp 638 Bytes
Newer Older
legoc's avatar
legoc committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include "Test.h"
#include "../include/Strings.h"
#include <iostream>

using namespace std;
using namespace cameo;

int main(int argc, char *argv[]) {

	CAMEO_ASSERT_TRUE("my-app.31" == NameId("my-app", 31).toString());

	NameId nameId = NameId::parse("my-app.31");

	CAMEO_ASSERT_TRUE("my-app" == nameId.getName());
15
16
	CAMEO_ASSERT_TRUE(nameId.getId().has_value());
	CAMEO_ASSERT_EQUAL(31, nameId.getId().value());
legoc's avatar
legoc committed
17
18

	nameId = NameId::parse("my-app32");
19
	CAMEO_ASSERT_TRUE(!nameId.getId().has_value());
legoc's avatar
legoc committed
20
21
22
23
24
25
26
27
28
29
30
31

	bool error = false;
	try {
		NameId::parse("my-app.ff");
	}
	catch (...) {
		error = true;
	}
	CAMEO_ASSERT_TRUE(error);

	return 0;
}