FTQuant  0.1
u_SyntaxParser.cpp
Go to the documentation of this file.
1 
4 #include <gtest/gtest.h>
5 #include <SyntaxParser.hpp>
6 
7 TEST(BadInputs, Subtest_1) {
8  Command A1("SDS DSA 1 DSW 3");
9  EXPECT_EQ(A1.code(), INVALID_COMMAND);
10 
11  Command B1(
12  "TRAJECTORIES_NUMBER TRAJECTORIES_NUMBER 5 TRAJECTORIES_NUMBER 12");
13  EXPECT_EQ(B1.code(), INVALID_COMMAND);
14 
15  Command C1("GENERATE_TRAJECTORIES TRAJECTORIES_NUMBER 5");
16  EXPECT_EQ(C1.code(), INVALID_COMMAND);
17 
18  Command D1("GENERATE_TRAJECTORIES TRAJECTORIES_NUMBER 5 STEPS_NUMBER 12a");
19  EXPECT_EQ(D1.code(), INVALID_COMMAND);
20 }
21 
22 TEST(IsCorrectData, Subtest_2) {
23  Command A2(
24  "BLACK_SCHOLES INTEREST_RATE 0.14 SIGMA 0.8 EXP_T 1. SPOT_PRICE 1.");
25  EXPECT_EQ(A2.to_json(),
26  "{code: 0, keyNumbers: [EXP_T] = 1.; [INTEREST_RATE] = 0.14; [SIGMA] = 0.8; [SPOT_PRICE] = 1.; }");
27 
28  Command B2(
29  "EURO_CALL ERROR 0.01 STRIKE_PRICE 100 TRAJECTORIES_NUMBER 100 STEPS_NUMBER 1000 EXP_T 1. SPOT_PRICE 100.");
30  EXPECT_EQ(B2.to_json(),
31  "{code: 5, keyNumbers: [ERROR] = 0.01; [EXP_T] = 1.; [SPOT_PRICE] = 100.; [STEPS_NUMBER] = 1000; [STRIKE_PRICE] = 100; [TRAJECTORIES_NUMBER] = 100; }");
32 }
Container for the commands Class contains the parsed command.
int code() const
std::string to_json() const
TEST(BadInputs, Subtest_1)