@@ -13,13 +13,13 @@ static std::vector<std::string> eventTracker;
1313
1414void appendNextIndex (const WorkerEvent* event);
1515std::vector<std::string> generateFibonacci (int length);
16- long sequenceComparison (const std::vector<std::string> &sequence1, const std::vector<std::string> &sequence2);
16+ long long sequenceComparison (const std::vector<std::string> &sequence1, const std::vector<std::string> &sequence2);
1717
1818
1919TEST (MessageProcessingTest, MessagesAreProcessed) {
2020 try {
2121 MessageEventManager eventManager{[](WorkerEvent* event)->void {appendNextIndex (event);}};
22- const int NUM_ITERATIONS = 100 ;
22+ const int NUM_ITERATIONS = 50 ;
2323 for (int i = 0 ; i < NUM_ITERATIONS; ++i) {
2424 JobEvent::Status status;
2525 switch (i + 1 ) {
@@ -45,8 +45,8 @@ void appendNextIndex(const WorkerEvent* event) {
4545 } else if (1 == eventTracker.size ()) {
4646 eventTracker.emplace_back (" 1" );
4747 } else {
48- const long firstValue = std::stol (eventTracker[eventTracker.size () - 2 ]);
49- const long secondValue = std::stol (eventTracker[eventTracker.size () - 1 ]);
48+ const long long firstValue = std::stoll (eventTracker[eventTracker.size () - 2 ]);
49+ const long long secondValue = std::stoll (eventTracker[eventTracker.size () - 1 ]);
5050 const std::string nextValue{std::to_string (firstValue + secondValue)};
5151 eventTracker.push_back (nextValue);
5252 }
@@ -61,20 +61,20 @@ std::vector<std::string> generateFibonacci(const int length) {
6161 for (int i = 0 ; i < length; ++i) {
6262 if (i == 0 ) { sequence.emplace_back (" 0" ); continue ; }
6363 if (i == 1 ) { sequence.emplace_back (" 1" ); continue ; }
64- const long firstValue = std::stol (sequence[sequence.size () - 2 ]);
65- const long secondValue = std::stol (sequence[sequence.size () - 1 ]);
64+ const long long firstValue = std::stoll (sequence[sequence.size () - 2 ]);
65+ const long long secondValue = std::stoll (sequence[sequence.size () - 1 ]);
6666 const std::string nextValue{std::to_string (firstValue + secondValue)};
6767 sequence.push_back (nextValue);
6868 }
6969 return sequence;
7070}
7171
72- long sequenceComparison (const std::vector<std::string> &sequence1, const std::vector<std::string> &sequence2) {
72+ long long sequenceComparison (const std::vector<std::string> &sequence1, const std::vector<std::string> &sequence2) {
7373 if (const size_t comp = sequence2.size () - sequence1.size (); comp) return static_cast <int >(comp);
7474 for (size_t i = 0 ; i < sequence1.size (); ++i) {
75- const long firstValue = std::stol (sequence1[i]);
76- const long secondValue = std::stol (sequence2[i]);
77- if (const long comp = secondValue - firstValue; comp) return comp;
75+ const long long firstValue = std::stoll (sequence1[i]);
76+ const long long secondValue = std::stoll (sequence2[i]);
77+ if (const long long comp = secondValue - firstValue; comp) return comp;
7878 }
7979 return 0 ;
8080}
0 commit comments