Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test{Float,Double}Matrix.testToString() are failing in French locale. #40

Merged
merged 2 commits into from Mar 6, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
69 changes: 69 additions & 0 deletions src/test/java/org/jblas/AbstractTestJblas.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// --- BEGIN LICENSE BLOCK ---
/*
* Copyright (c) 2009, Mikio L. Braun
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* * Neither the name of the Technische Universität Berlin nor the
* names of its contributors may be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// --- END LICENSE BLOCK ---
package org.jblas;

import org.junit.AfterClass;
import org.junit.BeforeClass;

import java.util.Locale;

import static java.util.Locale.*;

/**
* Abstract test class that all tests can extend.
* For now it is used to
*/
public abstract class AbstractTestJblas
{
/**
* This will contain the default locale of the system.
* It will then be used to set the locale back at the end of the tests.
*/
protected static Locale systemDefaultLocale;

@BeforeClass
public static void setEnglishLocale ()
{
systemDefaultLocale = getDefault();
setDefault( ENGLISH );
}

@AfterClass
public static void setBackSystemDefaultLocale ()
{
setDefault( systemDefaultLocale );
}
}
4 changes: 2 additions & 2 deletions src/test/java/org/jblas/TestDoubleMatrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

import static org.junit.Assert.*;

public class TestDoubleMatrix {
public class TestDoubleMatrix extends AbstractTestJblas {

//FLOAT// private final float eps = 1e-6f;
private final double eps = 1e-16;
Expand Down Expand Up @@ -719,7 +719,7 @@ public void testToString() {
// We have to be a bit cautious here because my Double => Float converter scripts will
// add a "f" to every floating point number, even in the strings. Therefore, I
// explicitly remove all "f"s
assertEquals("[1.000000, 5.000000, 9.000000; 2.000000, 6.000000, 10.000000; 3.000000, 7.000000, 11.000000; 4.000000, 8.000000, 12.000000]".replaceAll("f", ""), A.toString());
assertEquals( "[1.000000, 5.000000, 9.000000; 2.000000, 6.000000, 10.000000; 3.000000, 7.000000, 11.000000; 4.000000, 8.000000, 12.000000]".replaceAll( "f", "" ), A.toString() );

assertEquals("[1.0, 5.0, 9.0; 2.0, 6.0, 10.0; 3.0, 7.0, 11.0; 4.0, 8.0, 12.0]".replaceAll("f", ""), A.toString("%.1f"));

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/jblas/TestFloatMatrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

import static org.junit.Assert.*;

public class TestFloatMatrix {
public class TestFloatMatrix extends AbstractTestJblas {

private final float eps = 1e-6f;

Expand Down Expand Up @@ -718,7 +718,7 @@ public void testToString() {
// We have to be a bit cautious here because my Float => Float converter scripts will
// add a "f" to every floating point number, even in the strings. Therefore, I
// explicitly remove all "f"s
assertEquals("[1.000000f, 5.000000f, 9.000000f; 2.000000f, 6.000000f, 10.000000f; 3.000000f, 7.000000f, 11.000000f; 4.000000f, 8.000000f, 12.000000f]".replaceAll("f", ""), A.toString());
assertEquals( "[1.000000f, 5.000000f, 9.000000f; 2.000000f, 6.000000f, 10.000000f; 3.000000f, 7.000000f, 11.000000f; 4.000000f, 8.000000f, 12.000000f]".replaceAll( "f", "" ), A.toString() );

assertEquals("[1.0f, 5.0f, 9.0f; 2.0f, 6.0f, 10.0f; 3.0f, 7.0f, 11.0f; 4.0f, 8.0f, 12.0f]".replaceAll("f", ""), A.toString("%.1f"));

Expand Down