Skip to content

Commit

Permalink
fix package lock conflict [publish binary]
Browse files Browse the repository at this point in the history
  • Loading branch information
tuananh committed Jul 4, 2017
2 parents 9851bd6 + 7753fc4 commit 6e26c76
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "camaro",
"version": "1.1.5",
"version": "1.1.6",
"description": "Transforming XML to JSON using Node.js binding to native pugixml parser library",
"homepage": "https://github.com/tuananh/camaro",
"bugs": "https://github.com/tuananh/camaro/issues",
Expand Down
3 changes: 2 additions & 1 deletion src/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ void title_case(std::string&);

inline void title_case(std::string& str) {
lower(str);
static char last = ' ';
std::for_each(str.begin(), str.end(), [](char& c) {
static int last = ' ';
if (last == ' ' && c != ' ' && ::isalpha(c)) c = ::toupper(c);
last = c;
});
last = ' ';
}

inline void lower(std::string& str) {
Expand Down
30 changes: 23 additions & 7 deletions test/function.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,41 @@ const xml = `
<number>10.2</number>
<number>20.3</number>
<boolean>TrUe</boolean>
<string>HELLo WorLD</string>
<items>
<item>hEllo WorlD</item>
<item>Hello World</item>
<item>hello wOrld</item>
</items>
</root>
`

t.test('test function upper-case()', (t) => {
const result = transform(xml, { upperCase: 'upper-case(root/string)' })
t.equal(result.upperCase, 'HELLO WORLD')
const result = transform(xml, {
upperCase: ['//items/item', 'upper-case(.)']
})
result.upperCase.forEach(u => {
t.equal(u, 'HELLO WORLD')
})
t.end()
})

t.test('test function lower-case()', (t) => {
const result = transform(xml, { lowerCase: 'lower-case(root/string)' })
t.equal(result.lowerCase, 'hello world')
const result = transform(xml, {
lowerCase: ['//items/item', 'lower-case(.)']
})
result.lowerCase.forEach(u => {
t.equal(u, 'hello world')
})
t.end()
})

t.test('test function title-case()', (t) => {
const result = transform(xml, { titleCase: 'title-case(root/string)' })
t.equal(result.titleCase, 'Hello World')
const result = transform(xml, {
titleCase: ['//items/item', 'title-case(.)']
})
result.titleCase.forEach(u => {
t.equal(u, 'Hello World')
})
t.end()
})

Expand Down

0 comments on commit 6e26c76

Please sign in to comment.