Lolly 1.4.27
Loading...
Searching...
No Matches
Functions
sha_test.cpp File Reference
#include "a_lolly_test.hpp"
#include "file.hpp"
#include "lolly/hash/sha.hpp"
Include dependency graph for sha_test.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("sha224_hexdigest")
 
 TEST_CASE ("sha256_hexdigest")
 

Function Documentation

◆ TEST_CASE() [1/2]

TEST_CASE ( "sha224_hexdigest" )

Definition at line 19 of file sha_test.cpp.

19 {
20 SUBCASE ("normal file") {
21 string_eq (sha224_hexdigest (url_pwd () * "LICENSE"),
22 "2f051189f6ddb2d2fd11faeb8cf3e3b38b4216f2798ce1d92421e129");
23 }
24 SUBCASE ("empty file") {
25 url temp= url_temp ();
26 string_save ("", temp);
27 CHECK_EQ (file_size (temp), 0);
28 string_eq (sha224_hexdigest (temp),
29 "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f");
30 }
31 SUBCASE ("invalid file") {
32 string_eq (sha224_hexdigest (url_system ("https://mogan.app")), "");
33 string_eq (sha224_hexdigest (url_system ("/path/to/not_exist")), "");
34 }
35}
The list class represents a linked list.
Definition list.hpp:48
Definition url.hpp:37
void string_save(const string &s, url u)
Definition file.cpp:496
url url_temp(string suffix)
Definition file.cpp:274
int file_size(url u)
Definition file.cpp:155
void string_eq(string left, string right)
url url_system(string name)
Definition url.cpp:306
url url_pwd()
Definition url.cpp:326

◆ TEST_CASE() [2/2]

TEST_CASE ( "sha256_hexdigest" )

Definition at line 37 of file sha_test.cpp.

37 {
38 SUBCASE ("normal file") {
39 string_eq (
40 sha256_hexdigest (url_pwd () * "LICENSE"),
41 "8ceb4b9ee5adedde47b31e975c1d90c73ad27b6b165a1dcd80c7c545eb65b903");
42 }
43 SUBCASE ("empty file") {
44 url temp= url_temp ();
45 string_save ("", temp);
46 CHECK_EQ (file_size (temp), 0);
47 string_eq (
48 sha256_hexdigest (temp),
49 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
50 }
51 SUBCASE ("invalid file") {
52 string_eq (sha256_hexdigest (url_system ("https://mogan.app")), "");
53 string_eq (sha256_hexdigest (url_system ("/path/to/not_exist")), "");
54 }
55}