柴抛出相同对象的断言错误

时间:2018-07-04 18:46:34

标签: chai

我正在使用#include <iostream> #include <vector> #include <algorithm> class data { public: int group; bool condition; int time; friend bool operator==(const data& lhs, const data& rhs); data(int g, bool c, int t) { group = g; condition = c; time = t; } }; bool operator==(const data& lhs, const data& rhs) { return lhs.group == rhs.group; } int main(int argc, char**) { data info_1(10, true , 1); data info_2(20, true, 1); data info_3(10, false, 4); std::vector<data> data_vector; data_vector.push_back(info_1); data_vector.push_back(info_2); std::replace(data_vector.begin(), data_vector.end(), data_vector ,info_3); std::cout << "vector size: " << data_vector.size() << "\n"; for (int i = 0; i < data_vector.size(); i++) { std::cout << "group number: " << data_vector[i].group << std::boolalpha << " condition: " << data_vector[i].condition << "\n"; } system("pause"); return 0; } 来深化相等的对象并出错:

chai

我的代码非常简单:

AssertionError: expected { stringField: 'Test' } to deeply equal { stringField: 'Test' }
      + expected - actual

可能不只是比较字段,而且输出中未显示。

const json = Utils.getJsonFromMessage(message);
expect(json.structField).to.deep.equal({'stringField': 'Test'});

0 个答案:

没有答案