/** Test pcap dlt and do name to value comparison. */ public void testPcapDLTAndDoNameToValueComparison() { int match = 0; // counts how many constants compared OK for (PcapDLT c : PcapDLT.values()) { int dlt = c.value; String libName = Pcap.datalinkValToName(dlt); if (libName == null) { // System.out.printf("no dlt: dlt=%d enum=%s\n", dlt, c.toString()); continue; } if (libName.equals(c.name())) { match++; // System.out.printf("matched: dlt=%d enum=%s pcap=%s desc=%s\n", dlt, c // .toString(), libName, c.description); } else { // System.out.printf("unmatched: dlt=%d enum=%s pcap=%s desc=%s\n", dlt, // c // .toString(), libName, c.description); } } // System.out.println("Have " + match + " matches out of " // + PcapDLT.values().length); assertTrue("Something is wrong, most constants should match native pcap library", match > 20); // for (int dlt = 0; dlt < 100; dlt ++) { // String libName = Pcap.datalinkValToName(dlt); // PcapDLT c = PcapDLT.valueOf(dlt); // // if (c == null && libName != null) { // System.out.printf("We don't have dlt=%d pcap=%s\n", dlt, libName); // } // } }
/** Test datalink value to name. */ public void testDatalinkValueToName() { assertEquals("EN10MB", Pcap.datalinkValToName(1)); }