Skip to content

Commit

Permalink
[lib] refs #902 - Test cases for DecodeBase58Address function exporte…
Browse files Browse the repository at this point in the history
…d in static libskycoin

libskycoin tests powered by [Criterion](https://github.com/Snaipe/Criterion/)

Synthesis: Tested: 2 | Passing: 0 | Failing: 2 | Crashing: 0
  • Loading branch information
olemis committed Jan 28, 2018
1 parent fbb7e57 commit 493d2e0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ electron/.standalone_output

.vscode/

*.swo
*.swp

src/mesh/TODO

.idea/
Expand Down
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@ test: ## Run tests
build-lib-c: # Build Skycoinlib C
mkdir -p $(BUILDLIB_DIR)
rm -Rf $(BUILDLIB_DIR)/*
go build -buildmode=c-shared -o $(BUILDLIB_DIR)/skycoinlib.so $(LIB_DIR)/cgo/main.go
go build -buildmode=c-archive -o $(BUILDLIB_DIR)/skycoinlib.a $(LIB_DIR)/cgo/main.go
go build -buildmode=c-shared -o $(BUILDLIB_DIR)/libskycoin.so $(LIB_DIR)/cgo/main.go
go build -buildmode=c-archive -o $(BUILDLIB_DIR)/libskycoin.a $(LIB_DIR)/cgo/main.go

test-lib-c: build-lib-c
cp $(LIB_DIR)/cgo/tests/*.c $(BUILDLIB_DIR)/
rm $(BUILDLIB_DIR)/libskycoin.so # TODO: Get rid of this step
gcc -o $(BUILDLIB_DIR)/skycoinlib_test $(BUILDLIB_DIR)/*.c -I$(BUILDLIB_DIR) -lcriterion -lskycoin -L $(BUILDLIB_DIR)
$(BUILDLIB_DIR)/skycoinlib_test

lint: ## Run linters. Use make install-linters first.
vendorcheck ./...
Expand Down
27 changes: 27 additions & 0 deletions lib/cgo/tests/check_cipher.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

#include <criterion/criterion.h>
#include "libskycoin.h"

#define SKYCOIN_ADDRESS_VALID "12345678"
#define SKYCOIN_ADDRESS_WRONG "12345678"

Test(cipher, test_address_valid) {
GoString strAddr = {
SKYCOIN_ADDRESS_VALID,
8
};

struct DecodeBase58Address_return r = DecodeBase58Address(strAddr);
cr_assert(r.r1 == 1);
}

Test(cipher, test_address_wrong) {
GoString strAddr = {
SKYCOIN_ADDRESS_VALID,
8
};

struct DecodeBase58Address_return r = DecodeBase58Address(strAddr);
cr_assert(r.r1 == 0);
}

0 comments on commit 493d2e0

Please sign in to comment.