Git Product home page Git Product logo

i18n_sanitycheck's Introduction

i18n-sanitychecker is a library that allows developer to write unit-test for locale-sensitive functions without relying on "golden data".

i18n-sanitychecker provides only one public method to match actual strings against expected patterns. Patterns may contain placeholders for date, time, numbers, lists. The method behaves similar to other assert methods of JUnit.

#Usage

SanityCheckProcessor.assertI18nSanityCheck(pattern, actual_string, locale);

#Examples

  1. Check that DOM element contains date and time in any format for Japanese:
SanityCheckProcessor.assertI18nSanityCheck("{datetime}",
    dom.getSingleNodeText("//abbr[@class='timestamp']"), ULocale.JAPAN);
  1. Check that string contains date in any format suitable for German:
SanityCheckProcessor.assertI18nSanityCheck(
    "Todays is {date}", formatted_string, Locale.GERMAN);
  1. Check that value is a date formatted according the pattern:
SanityCheckProcessor.assertI18nSanityCheck(
    "{datetime:{pattern:'dd-MM-yy'}}", value, currentLocale)

#Placeholders

Placeholder Description
{ignore} Ignores everything within this placeholder.
{time} Checks if formatted time satisfies ICU standards.
{date} Checks if formatted date satisfies the ICU standards
{datetime} Merges 2 and 3 together. Has same optional parameters.
{number} Checks if formatted number satisfies the ICU standards. ould be used to check currency, rational, scientific, numbers and spelled numbers.
{locale} Checks if locale code matches.
{timezone} Checks if timezone matches.
{sorting} Checks if the elements within the placeholder were sorted correctly according to the locale rules.
{period} checks if date time period is correct.

#Additional parameters for placeholders

Parameter Applies To Description
pattern date, time, datetime ICU formatting pattern (see ICU documentation for details).
skeleton date, time, datetime ICU skeleton - less restrictive than pattern
value date, time, datetime, number actual value in numeric locale-independent format. For date and time - milliseconds since Jan 1, 1970
lenient date, time, datetime, number, timezone Relax format validation rules
strict sorting Apply more strict sorting rules (see ICU documentation)

i18n_sanitycheck's People

Contributors

iverg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.