/* Ċ Ġ* ĠCopyright Ġ 2 0 1 0 - 2 0 2 1 ĠJetBrains Ġs . r . o . Ġand ĠKotlin ĠProgramming ĠLanguage Ġcontributors . Ċ Ġ* ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense Ġthat Ġcan Ġbe Ġfound Ġin Ġthe Ġlicense / LICENSE . txt Ġfile . Ċ Ġ*/ Ċ Ċ package Ġorg . jetbrains . kotlin . gradle . incremental Ċ Ċ import Ġorg . junit . Assert .* Ċ import Ġorg . junit . Test Ċ Ċ abstract Ġclass ĠClass path Snapshot Serializer Test Ġ: ĠClass path Snapshot Test Common () Ġ{ ĊĊĠĠĠ Ġprotected Ġabstract Ġval Ġtest SourceFile : ĠChange able Test SourceFile ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġopen Ġfun Ġ` test ĠClass Snapshot Data Serializer `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġoriginal Snapshot Ġ= Ġtest SourceFile . compile And Snapshot () ĊĠĠĠĠĠĠĠ Ġval Ġserialized Snapshot Ġ= ĠClass Snapshot Data Serializer . toByteArray ( original Snapshot ) ĊĠĠĠĠĠĠĠ Ġval Ġdeserialized Snapshot Ġ= ĠClass Snapshot Data Serializer . from ByteArray ( serialized Snapshot ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( original Snapshot . to Gson (), Ġdeserialized Snapshot . to Gson ()) ĊĠĠĠ Ġ} Ċ } Ċ Ċ class ĠKotlin Classes Classpath Snapshot Serializer Test Ġ: ĠClass path Snapshot Serializer Test () Ġ{ ĊĠĠĠ Ġoverride Ġval Ġtest SourceFile Ġ= ĠSimple Kotlin Class ( tmp Dir ) Ċ } Ċ Ċ class ĠJava Classes Classpath Snapshot Serializer Test Ġ: ĠClass path Snapshot Serializer Test () Ġ{ ĊĊĠĠĠ Ġoverride Ġval Ġtest SourceFile Ġ= ĠSimple Java Class ( tmp Dir ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġoverride Ġfun Ġ` test ĠClass Snapshot Data Serializer `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġoriginal Snapshot Ġ= Ġtest SourceFile . compile And Snapshot () ĊĠĠĠĠĠĠĠ Ġval Ġserialized Snapshot Ġ= ĠClass Snapshot Data Serializer . toByteArray ( original Snapshot ) ĊĠĠĠĠĠĠĠ Ġval Ġdeserialized Snapshot Ġ= ĠClass Snapshot Data Serializer . from ByteArray ( serialized Snapshot ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠThe Ġdeserialized Ġobject Ġdoes Ġnot Ġexactly Ġmatch Ġthe Ġoriginal Ġobject Ġas Ġthey Ġcontain Ġfields Ġcalled Ġ` memo ized Serialized Size ` Ġwhich ĊĠĠĠĠĠĠĠ Ġ// Ġare Ġnot Ġpart Ġof Ġthe Ġserialized Ġdata Ġand Ġtheir Ġvalues Ġseem Ġto Ġbe Ġgenerated Ġseparately . ĠTherefore , Ġwe Ġremove Ġthese Ġfields Ġfrom Ġthe ĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġbelow . ĊĠĠĠĠĠĠĠ Ġassert Not Equals ( original Snapshot . to Gson (), Ġdeserialized Snapshot . to Gson ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoriginal Snapshot . to Gson (). strip Lines Containing Text (" memo ized Serialized Size "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdeserialized Snapshot . to Gson (). strip Lines Containing Text (" memo ized Serialized Size ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ// ĠAdd Ġanother Ġcheck Ġto Ġconfirm Ġthat Ġthose Ġfields Ġare Ġnot Ġpart Ġof Ġthe Ġserialized Ġdata . ĊĠĠĠĠĠĠĠ Ġassert ArrayEquals ( serialized Snapshot , ĠClass Snapshot Data Serializer . toByteArray ( de serialized Snapshot )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠString . strip Lines Containing Text ( text : ĠString ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġlines (). filter Not Ġ{ Ġit . contains ( text , Ġignore Case Ġ= Ġtrue ) Ġ}. join ToString ("\ n ") ĊĠĠĠ Ġ} Ċ } Ċ