-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c8e410
commit 7a8deb3
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# This file is part of ICU4X. For terms of use, please see the file | ||
# called LICENSE at the top level of the ICU4X source tree | ||
# (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). | ||
|
||
.DEFAULT_GOAL := test | ||
.PHONY: build test | ||
|
||
ALL_HEADERS := $(wildcard ../include/*.h) | ||
ALL_RUST := $(wildcard ../src/*.rs) | ||
|
||
$(ALL_RUST): | ||
|
||
$(ALL_HEADERS): | ||
|
||
|
||
../../../target/debug/libicu_capi.a: $(ALL_RUST) | ||
cargo build | ||
|
||
a.out: ../../../target/debug/libicu_capi.a $(ALL_HEADERS) | ||
gcc test.c ../../../target/debug/libicu_capi.a -ldl -lpthread -lm | ||
|
||
build: a.out | ||
|
||
test: build | ||
./a.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// This file is part of ICU4X. For terms of use, please see the file | ||
// called LICENSE at the top level of the ICU4X source tree | ||
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). | ||
|
||
#include "../include/pluralrules.h" | ||
#include <string.h> | ||
#include <stdio.h> | ||
|
||
const char* path = "../../../resources/testdata/data/json/"; | ||
int main() { | ||
Locale* locale = locale_create("ar", 2); | ||
CreateDataProviderResult result = fs_data_provider_create(path, strlen(path)); | ||
if (!result.success) { | ||
printf("Failed to create FsDataProvider\n"); | ||
return 1; | ||
} | ||
ErasedDataProvider provider = result.provider; | ||
CreatePluralRulesResult plural_result = plural_rules_create(locale, &provider, PluralRuleType_Cardinal); | ||
if (!plural_result.success) { | ||
printf("Failed to create PluralRules\n"); | ||
return 1; | ||
} | ||
PluralRules* rules = plural_result.rules; | ||
|
||
PluralOperands op; | ||
op.i = 3; | ||
|
||
PluralCategory cat = plural_rules_select(rules, &op); | ||
|
||
printf("Plural Category %d (should be %d)\n", (int)cat, (int)PluralCategory_Few); | ||
|
||
plural_rules_destroy(rules); | ||
erased_data_provider_destroy(provider); | ||
locale_destroy(locale); | ||
|
||
if (cat != PluralCategory_Few) { | ||
return 1; | ||
} | ||
return 0; | ||
} |