1
0
forked from 0ad/0ad

Adds collision test for fnv_hash, removes unused include forgotten in b4a33851e6.

This was SVN commit r26007.
This commit is contained in:
Vladislav Belov 2021-11-21 11:59:02 +00:00
parent ab01a2d2fc
commit 25ce179cbc
2 changed files with 9 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2017 Wildfire Games.
/* Copyright (C) 2021 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -22,7 +22,6 @@
#include <boost/algorithm/string.hpp>
#include "graphics/ModelDef.h"
#include "lib/fnv_hash.h"
#include "maths/MD5.h"
#include "ps/CacheLoader.h"
#include "ps/CLogger.h"

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2010 Wildfire Games.
/* Copyright (C) 2021 Wildfire Games.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -40,4 +40,11 @@ public:
TS_ASSERT_EQUALS(h2, 0xD80BDA3FBE244A0Aull); // verify value for simple string
TS_ASSERT_EQUALS(fnv_hash64("abcdef", 6), h2); // same result if hashing buffer
}
void test_collisions()
{
TS_ASSERT_EQUALS(fnv_hash("collisions", 10), fnv_hash("silage_formism", 14));
TS_ASSERT_EQUALS(fnv_hash("2018-04-13 06:10", 16), fnv_hash("1984-05-01 06:20", 16));
TS_ASSERT_EQUALS(fnv_hash("etude", 5), fnv_hash("nonassister", 11));
}
};