<commit_before>#include <limits.h>
#include "dhasher.h"
#include "gtest/gtest.h"

TEST(DHasherTest, Trivial) {
  dhash v1 = 0b1001;
  dhash v2 = 0b0101;
  EXPECT_EQ(DHasher::Instance()->CalculateHammingDistance(v1, v2), 2);
}

TEST(DHasherTest, Full64BitRange) {
  dhash v1 = (dhash)0x0300000000000010;
  dhash v2 = (dhash)0x0400000000000020;
  EXPECT_EQ(DHasher::Instance()->CalculateHammingDistance(v1, v2), 5);
}<commit_msg>add test for dhash pixmap<commit_after>#include <limits.h>
#include "dhasher.h"
#include "gtest/gtest.h"

#include <QApplication>

TEST(DHasherTest, HammingTrivial) {
  dhash v1 = 0b1001;
  dhash v2 = 0b0101;
  EXPECT_EQ(DHasher::Instance()->CalculateHammingDistance(v1, v2), 2);
}

TEST(DHasherTest, HammingFull64BitRange) {
  dhash v1 = (dhash)0x0300000000000010;
  dhash v2 = (dhash)0x0400000000000020;
  EXPECT_EQ(DHasher::Instance()->CalculateHammingDistance(v1, v2), 5);
}

TEST(DHasherTest, HashOfSimplePixmap) {
  int argc = 0;
  char **argv = NULL;
  QApplication app(argc, argv);
  QImage test(9,8, QImage::Format_RGB888);

  QRgb white = QColor(255, 255, 255).rgb();
  QRgb black = QColor(0, 0, 0).rgb();

  test.fill(black);

  test.setPixel(1, 0, white);
  test.setPixel(2, 1, white);
  test.setPixel(3, 2, white);
  test.setPixel(4, 3, white);
  test.setPixel(5, 4, white);
  test.setPixel(6, 5, white);
  test.setPixel(7, 6, white);
  test.setPixel(8, 7, white);

  dhash value = DHasher::Instance()->HashOfPixmap(QPixmap::fromImage(test));

  EXPECT_EQ(value, 0x8040201008040201);
}
{'fraction_non_alphanumeric': 0.1580327868852459, 'fraction_numerical': 0.10688524590163935, 'mean_word_length': 5.606060606060606, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '77533', 'n_tokens_mistral': 744, 'n_tokens_neox': 627, 'n_words': 116}