Skip to content

Commit

Permalink
Minor test refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 20, 2024
1 parent 9e64875 commit 3f933e8
Showing 1 changed file with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public class WriteSimpleTest extends TestBase
{
final static class POJO {
static class POJO {
public int value = 3;

public POJO() { }
Expand All @@ -22,12 +22,20 @@ public POJO() { }

enum ABC { A, B, C; }

final static class Address {
static class Address {
public String name;

public Address(String n) { name = n; }
}


static class PathWrapper {
public Path path;

public PathWrapper(Path p) {
path = p;
}
}

/*
/**********************************************************************
/* Test methdods
Expand Down Expand Up @@ -102,18 +110,30 @@ public void testNest() throws Exception
JSON.std.asString(stuff));
}

public void testKnownSimpleTypes() throws Exception
public void testKnownSimpleTypeURI() throws Exception
{
final String URL_STR = "http://fasterxml.com";
final URI uri = new URI(URL_STR);
assertEquals(q(URL_STR), JSON.std.asString(uri));
}

public void testKnownSimpleTypeFile() throws Exception
{
final String PATH = "/foo/bar.txt";
assertEquals(q(PATH),
JSON.std.asString(new File(PATH)));
}

public void testKnownSimpleTypePath() throws Exception
{
Path p = Paths.get(new URI("file:///foo/bar.txt"));
assertEquals(q("file:///foo/bar.txt"), JSON.std.asString(p));

assertEquals(a2q("{'path':'file:///foo/bar.txt'}"), JSON.std.asString(new PathWrapper(p)));
}

public void testSimpleEnumTypes() throws Exception
{
assertEquals(q("B"), JSON.std.asString(ABC.B));
assertEquals("1", JSON.std.with(Feature.WRITE_ENUMS_USING_INDEX).asString(ABC.B));
}
Expand Down

0 comments on commit 3f933e8

Please sign in to comment.