Github user jpeach commented on a diff in the pull request: https://github.com/apache/trafficserver/pull/542#discussion_r58236316 --- Diff: proxy/hdrs/test_mime.cc --- @@ -0,0 +1,80 @@ +/** @file + + A brief file description + + @section license License + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + +#include "P_Eventsystem.h" +#include "MIME.h" + +static void +test_mime() +{ + int failed = 0; + MIMEField *field; + MIMEHdr hdr; + hdr.create(NULL); + + hdr.field_create("Test1", 5); + hdr.field_create("Test2", 5); + hdr.field_create("Test3", 5); + hdr.field_create("Test4", 5); + field = hdr.field_create("Test5", 5); + if (!hdr.m_mime->m_first_fblock.contains(field)) { + printf("FAILED: The field block doesn't contain the field but it should\n\n"); + failed = 1; + } + if (hdr.m_mime->m_first_fblock.contains(field + (1L << 32))) { + printf("FAILED: The field block contains the field but it shouldn't\n\n"); + failed = 1; + } + + int slot_num = mime_hdr_field_slotnum(hdr.m_mime, field); + if (slot_num != 4) { + printf("FAILED: Slot number is %d but should be 4\n\n", slot_num); + failed = 1; + } + + slot_num = mime_hdr_field_slotnum(hdr.m_mime, field + (1L << 32)); + if (slot_num != -1) { + printf("FAILED: Slot number is %d but should be -1\n\n", slot_num); + failed = 1; + } + + hdr.destroy(); + + printf("*** %s ***\n", (failed ? "FAILED" : "PASSED")); + if (failed) { + exit(1); + } +} + +int +main(int argc, char *argv[]) +{ + Thread *main_thread = new EThread; + main_thread->set_specific(); + mime_init(); + + test_mime(); --- End diff -- This is nice! Could you use ``<ts/TestBox.h>`` for the test harness? (see plugins/experimental/sslheaders/test_sslheaders.cc, for example).
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---