summaryrefslogtreecommitdiff
path: root/src/test.cpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-11-24 03:38:10 +0100
committerFlorent Le Coz <louiz@louiz.org>2014-11-24 03:38:10 +0100
commit0ab5ecea133cef5a009bc34ba42c4eaacde6a7dd (patch)
tree8967bca26572696144c99ec4e307c64b117f4875 /src/test.cpp
parent7bfe695c2f8ff4b365ab5c2d74b4a317518576e7 (diff)
downloadbiboumi-0ab5ecea133cef5a009bc34ba42c4eaacde6a7dd.tar.gz
biboumi-0ab5ecea133cef5a009bc34ba42c4eaacde6a7dd.tar.bz2
biboumi-0ab5ecea133cef5a009bc34ba42c4eaacde6a7dd.tar.xz
biboumi-0ab5ecea133cef5a009bc34ba42c4eaacde6a7dd.zip
Cache the result of jidprep()
Avoid doing repetitive calculations, if we call jidprep() on the same JID multiple times
Diffstat (limited to 'src/test.cpp')
-rw-r--r--src/test.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/test.cpp b/src/test.cpp
index 59c0a1e..2f29e01 100644
--- a/src/test.cpp
+++ b/src/test.cpp
@@ -288,7 +288,12 @@ int main()
// Jidprep
const std::string& badjid("~zigougou™@EpiK-7D9D1FDE.poez.io/Boujour/coucou/slt™");
const std::string correctjid = jidprep(badjid);
+ std::cout << correctjid << std::endl;
assert(correctjid == "~zigougoutm@epik-7d9d1fde.poez.io/Boujour/coucou/sltTM");
+ // Check that the cache do not break things when we prep the same string
+ // multiple times
+ assert(jidprep(badjid) == "~zigougoutm@epik-7d9d1fde.poez.io/Boujour/coucou/sltTM");
+ assert(jidprep(badjid) == "~zigougoutm@epik-7d9d1fde.poez.io/Boujour/coucou/sltTM");
const std::string& badjid2("Zigougou@poez.io");
const std::string correctjid2 = jidprep(badjid2);