Пример #1
0
  void test_find_representatives() {

    static const string useful_columns[] = {
      cFirstname::static_get_class_name(),
      cMiddlename::static_get_class_name(),
      cLastname::static_get_class_name(),
      cLatitude::static_get_class_name(),
      cAssignee::static_get_class_name(),
      cCity::static_get_class_name(),
      cCountry::static_get_class_name()
    };
    static const uint32_t numcols = sizeof(useful_columns)/sizeof(string);

    vector<uint32_t> indice = make_indice(useful_columns,numcols);

    Spec spec;
    spec.it("Indexing for find_representatives", [&indice](Description desc)->bool {
        vector<uint32_t> test = { 0, 2, 1, 7, 4, 10, 11 };
        return (test == indice);
    });


    const Record * r1 = rpv[1];
    const Record * r2 = rpv[2];
    const Record * r3 = rpv[3];

    typedef std::pair<const Attribute *, uint32_t> AttCount;
    typedef map<const Attribute *, uint32_t> AttCounts;
    RecordPList m_fellows = { r1, r2, r3 };
    vector<AttCounts> trace = make_trace(indice, m_fellows, numcols);

#if 0 /// Save all this it's really useful
    for_each(begin(trace), end(trace), [](AttCounts acs) {
        for_each(begin(acs), end(acs), [](AttCount ac) {
           const vector<const string*> & data = ac.first->get_data();
           for_each(begin(data), end(data), [](const string * s) {
              std::cout << "Att: " << s->c_str() << ", ";
           });
           std::cout << "count: " << ac.second << std::endl;
        });
    });
#endif

    vector<const Attribute *> most = get_most(trace, numcols);

    const Record * mp = get_record_with_most(most, m_fellows, indice, numcols);

    //mp->print();

    spec.it("Unique record ID for cluster representative should be 06453319-4", [mp](Description desc)->bool {
        const string uid = mp->get_unique_record_id();
        return (uid == string("06453319-4"));
    });

  }
Пример #2
0
  void testem_all() {

    Spec spec;

    spec.it("Comparing two empty strings scores 0", [this](Description desc)->bool {
      s1 = ""; s2 = "";
      int score = jwcmp(s1, s2);
      //print_score(s1, s2, score);
      return (0 == score);
    });


    spec.it("Comparing %s with %s results in %d", [this, &spec](Description desc)->bool {
      s1 = "MATTHEW"; s2 = "XYZ";
      int score = jwcmp(s1, s2);
      sprintf(spec.buf, desc, s1.c_str(), s2.c_str(), score);
      return (0 == score);
    });

    spec.it("Comparing %s with %s results in %d", [this, &spec](Description desc)->bool {
      s1 = "MATTHEW"; s2 = "TALIN";
      int score = jwcmp(s1, s2);
      sprintf(spec.buf, desc, s1.c_str(), s2.c_str(), score);
      return (0 == score);
    });


    spec.it("Comparing %s with %s results in %d", [this, &spec](Description desc)->bool {
      s1 = "MATTHEW"; s2 = "MATHEW";
      int score = jwcmp(s1, s2);
      sprintf(spec.buf, desc, s1.c_str(), s2.c_str(), score);
      return (4 == score);
    });


    spec.it("Comparing %s with %s results in %d", [this, &spec](Description desc)->bool {
      s1 = "MATTHEW"; s2 = "MATTHEW";
      int score = jwcmp(s1, s2);
      sprintf(spec.buf, desc, s1.c_str(), s2.c_str(), score);
      return (5 == score);
    });

  }
Пример #3
0
  void create_clusterhead() {

    Spec spec;

    Record * representative = make_foobar_record();
    spec.it("Creates a ClusterHead", [representative](Description desc)->bool {
      double cohesion = 0.9953;
      ClusterHead ch(representative, cohesion);
      return (cohesion == ch.m_cohesion);
    });
    // Segfaults...
    //r->print();
    // segfaults, which shouldn't be...
    // Leaks, bad
    //r->clean_member_attrib_pool();
    //std::cout << "sizeof(r): " << sizeof(*r) << std::endl;
    delete representative;
  }