Skip to content
This repository has been archived by the owner on Feb 5, 2020. It is now read-only.

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Howe committed Oct 17, 2018
1 parent 5ee1b61 commit 6aeaab3
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: 2

jobs:
build:
docker:
- image: abronan/rust-circleci:latest

steps:
- checkout
- restore_cache:
key: project-cache
- run:
name: Check formatting
command: |
rustfmt --version
cargo fmt -- --write-mode=diff
- run:
name: Nightly Build
command: |
rustup run nightly rustc --version --verbose
rustup run nightly cargo --version --verbose
rustup run nightly cargo build
- run:
name: Stable Build
command: |
rustup run stable rustc --version --verbose
rustup run stable cargo --version --verbose
rustup run stable cargo build
- run:
name: Test
command: rustup run stable cargo test --lib
- save_cache:
key: project-cache
paths:
- "~/.cargo"
- "./target"
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
members = [
"named_type",
"named_type_derive",
"named_type_test",
]
8 changes: 8 additions & 0 deletions named_type_test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "named_type_test"
version = "0.1.0"
authors = ["Christian Howe <cjhowe7@pm.me>"]

[dependencies]
named_type = { path = "../named_type" }
named_type_derive = { path = "../named_type_derive" }
43 changes: 43 additions & 0 deletions named_type_test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
extern crate named_type;
#[macro_use]
extern crate named_type_derive;

use named_type::NamedType;

#[derive(NamedType)]
struct MyStruct {}

#[test]
fn test_struct() {
assert_eq!(MyStruct::type_name(), concat!(module_path!(), "::MyStruct"));
assert_eq!(MyStruct::short_type_name(), "MyStruct");
}

#[derive(NamedType)]
enum MyEnum {}

#[test]
fn test_enum() {
assert_eq!(MyEnum::type_name(), concat!(module_path!(), "::MyEnum"));
assert_eq!(MyEnum::short_type_name(), "MyEnum");
}

#[derive(NamedType)]
#[named_type(short_prefix = "Pre")]
enum Prefixed {}

#[test]
fn test_prefix() {
assert_eq!(Prefixed::type_name(), concat!(module_path!(), "::Prefixed"));
assert_eq!(Prefixed::short_type_name(), "PrePrefixed");
}

#[derive(NamedType)]
#[named_type(short_suffix = "_suffix")]
struct Suffixed {}

#[test]
fn test_suffix() {
assert_eq!(Suffixed::type_name(), concat!(module_path!(), "::Suffixed"));
assert_eq!(Suffixed::short_type_name(), "Suffixed_suffix");
}

0 comments on commit 6aeaab3

Please sign in to comment.