Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 34 lines (25 sloc) 0.92 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -pa ../src -sasl errlog_type error -boot start_sasl -noshell

-record(location, {region, country}).
-record(person, {name, address, phone_number, age, location}).

main(_) ->
    etap:plan(2),
    etap:is(protobuffs_compile:scan_file("hasdefault.proto"), ok, "hasdefault.proto created"),

Person = #person {
name = "Nick",
address = "Mountain View",
location = #location{region = "Lyon", country = "France"}
},

    DefaultPerson = #person{
     name = "Nick",
     address = "Mountain View",
        phone_number = "+1 (000) 000-0000",
age = 25,
location = #location{region = "Lyon", country = "France"}
    },

Bin = hasdefault_pb:encode_person(Person),

etap:is(hasdefault_pb:decode_person(Bin), DefaultPerson, "Default person encoded and decoded"),

ok = file:delete("hasdefault_pb.hrl"),
ok = file:delete("hasdefault_pb.beam"),

    etap:end_tests().
Something went wrong with that request. Please try again.