Example program to test JLANG::JString class.
More...
#include <string>
#include <iostream>
#include <fstream>
#include <locale>
#include <iomanip>
#include "JLang/JString.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
Go to the source code of this file.
|
| int | main (int argc, char **argv) |
| |
Example program to test JLANG::JString class.
- Author
- mdejong
Definition in file JString.cc.
◆ main()
| int main |
( |
int | argc, |
|
|
char ** | argv ) |
Definition at line 20 of file JString.cc.
21{
24
26
27 try {
28
29 JParser<> zap(
"Example program to test string operations.");
30
32
34 }
35 catch(const exception &error) {
37 }
38
39
40 {
41 const JString buffer(
"% = %;",
"key", 123);
42
44
45 ASSERT(buffer ==
"key = 123;",
"Test formatting");
46 }
47
48 {
50
52
53 buffer.toUpper();
54
56
57 ASSERT(buffer ==
"HELLO WORLD.",
"Test JString::toUpper()");
58
59 buffer.toLower();
60
62
63 ASSERT(buffer ==
"hello world.",
"Test JString::toLower()");
64 }
65
66 {
67 JString buffer(
"a = %1; b = %2; c = %3;");
68
69 buffer.replace("%1", 3.1415).replace("%2", "hello").replace("%3", 123);
70
72
73 ASSERT(buffer ==
"a = 3.1415; b = hello; c = 123;",
"Test JString::replace()");
74 }
75
76
77 {
78 int i = JString::toValue<int>("1234");
79
81
82 ASSERT(i == 1234,
"Test JString::toValue<int>()");
83 }
84
85 {
86 JString buffer(
"1 3.1415 hello");
87
88 int i;
89 double d;
90 string w;
91
92 buffer.assign(i).assign(d).assign(w);
93
95
96 ASSERT(i == 1 && d == 3.1415 && w ==
"hello",
"Test JString::assign()");
97 }
98}
#define DEBUG(A)
Message macros.
#define ASSERT(A,...)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Wrapper class around STL string class.
Template definition of a multi-dimensional oscillation probability interpolation table.
Utility class to parse command line options.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).