Skip to content

Commit

Permalink
base64 parsing fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrush committed Sep 30, 2016
1 parent 605a2a1 commit e6a7179
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/libs/conduit/Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ Generator::Parser::parse_base64(Node *node,
memset(decode_ptr,0,dec_buff_size);

utils::base64_decode(src_ptr,
dec_buff_size,
encoded_len,
decode_ptr);

node->set(s,decode_ptr);
Expand Down
2 changes: 1 addition & 1 deletion src/tests/conduit/python/t_python_conduit_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
###############################################################################
"""
file: python_conduit_generator.py
description: Unit tests for conduit::Geneartor python module interface.
description: Unit tests for conduit::Generator python module interface.
"""

Expand Down
33 changes: 30 additions & 3 deletions src/tests/conduit/t_conduit_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,17 +362,44 @@ TEST(conduit_json, to_base64_json)

nparse.print();

EXPECT_EQ(n["a"].as_uint32(),a_val);
EXPECT_EQ(n["b"].as_uint32(),b_val);
EXPECT_EQ(nparse["a"].as_uint32(),a_val);
EXPECT_EQ(nparse["b"].as_uint32(),b_val);

uint32 *arr_vals= n["arr"].value();
uint32 *arr_vals= nparse["arr"].value();

for(index_t i=0;i<5;i++)
{
EXPECT_EQ(arr_vals[i],arr[i]);
}
}

//-----------------------------------------------------------------------------
TEST(conduit_json, to_base64_json_2)
{

uint32 a_val = 10;
uint32 b_val = 20;
float64 c_val = 30.0;

Node n;
n["a"] = a_val;
n["b"] = b_val;
n["c"] = c_val;

std::string base64_json = n.to_json("conduit_base64_json");
std::cout << base64_json << std::endl;

Node nparse;
Generator g(base64_json,"conduit_base64_json");
g.walk(nparse);

nparse.print();

EXPECT_EQ(nparse["a"].as_uint32(),a_val);
EXPECT_EQ(nparse["b"].as_uint32(),b_val);
EXPECT_EQ(nparse["c"].as_float64(),c_val);
}


//-----------------------------------------------------------------------------
TEST(conduit_json, check_empty)
Expand Down
2 changes: 1 addition & 1 deletion src/tests/conduit/t_conduit_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ TEST(conduit_utils, base64_enc_dec)
memset(b64_decode_ptr,0,dec_buff_size);

utils::base64_decode(bb64_data.as_char8_str(),
dec_buff_size,
enc_buff_size,
b64_decode_ptr);

// apply schema
Expand Down

0 comments on commit e6a7179

Please sign in to comment.