Skip to content

Commit

Permalink
Stanza: Add parseXmlBool() helper
Browse files Browse the repository at this point in the history
  • Loading branch information
mwild1 committed Dec 5, 2024
1 parent 845bc30 commit 1028cd3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions snikket/Stanza.hx
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ class Stanza implements NodeInterface {
}
});
}

static public function parseXmlBool(x:String) {
return x == "true" || x == "1";
}
}

enum IqRequestType {
Expand Down
7 changes: 7 additions & 0 deletions test/TestStanza.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@ class TestStanza extends utest.Test {
}
Assert.equals(2, count);
}

public function testParseXmlBool() {
Assert.equals(true, Stanza.parseXmlBool("true"));
Assert.equals(true, Stanza.parseXmlBool("1"));
Assert.equals(false, Stanza.parseXmlBool("false"));
Assert.equals(false, Stanza.parseXmlBool("0"));
}
}

0 comments on commit 1028cd3

Please sign in to comment.