@@ -361,7 +361,22 @@ export class TaskMapAdapter<T> {
361361 // 他のメソッド (has, set, delete) も同様に実装
362362}
363363
364+ /**
365+ * Creates a unique key for a ContestTaskPair using contestId and taskId.
366+ * Throws an error if either argument is an empty string.
367+ *
368+ * @param contestId - The ID of the contest.
369+ * @param taskId - The ID of the task.
370+ * @returns A string in the format "contestId:taskId".
371+ * @throws Will throw an error if contestId or taskId is empty.
372+ */
364373export function createContestTaskPairKey(contestId : string , taskId : string ): ContestTaskPairKey {
374+ if (! contestId || contestId .trim () === ' ' ) {
375+ throw new Error (' contestId must be a non-empty string' );
376+ }
377+ if (! taskId || taskId .trim () === ' ' ) {
378+ throw new Error (' taskId must be a non-empty string' );
379+
365380 return ` ${contestId }:${taskId } ` ;
366381}
367382` ` `
@@ -569,6 +584,8 @@ describe('createContestTaskPairKey', () => {
569584 test (' expect to validate input parameters' , () => {
570585 expect (() => createContestTaskPairKey (' ' , ' task' )).toThrow ();
571586 expect (() => createContestTaskPairKey (' contest' , ' ' )).toThrow ();
587+ expect (() => createContestTaskPairKey (' ' , ' task' )).toThrow ();
588+ expect (() => createContestTaskPairKey (' contest' , ' ' )).toThrow ();
572589 });
573590});
574591` ` `
0 commit comments