GSI - Employe Self Service Mobile
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.4 KiB

2 months ago
  1. /*eslint-disable no-console*/
  2. "use strict";
  3. var protobuf = require("../../"),
  4. descriptor = require(".");
  5. /* var proto = {
  6. nested: {
  7. Message: {
  8. fields: {
  9. foo: {
  10. type: "string",
  11. id: 1
  12. }
  13. },
  14. nested: {
  15. SubMessage: {
  16. fields: {}
  17. }
  18. }
  19. },
  20. Enum: {
  21. values: {
  22. ONE: 1,
  23. TWO: 2
  24. }
  25. }
  26. }
  27. }; */
  28. // var root = protobuf.Root.fromJSON(proto).resolveAll();
  29. var root = protobuf.loadSync("tests/data/google/protobuf/descriptor.proto").resolveAll();
  30. // console.log("Original proto", JSON.stringify(root, null, 2));
  31. var msg = root.toDescriptor();
  32. // console.log("\nDescriptor", JSON.stringify(msg.toObject(), null, 2));
  33. var buf = descriptor.FileDescriptorSet.encode(msg).finish();
  34. var root2 = protobuf.Root.fromDescriptor(buf, "proto2").resolveAll();
  35. // console.log("\nDecoded proto", JSON.stringify(root2, null, 2));
  36. var diff = require("deep-diff").diff(root.toJSON(), root2.toJSON());
  37. if (diff) {
  38. diff.forEach(function(diff) {
  39. console.log(diff.kind + " @ " + diff.path.join("."));
  40. console.log("lhs:", typeof diff.lhs, diff.lhs);
  41. console.log("rhs:", typeof diff.rhs, diff.rhs);
  42. console.log();
  43. });
  44. process.exitCode = 1;
  45. } else
  46. console.log("no differences");